سؤال

لدي برنامج نصي PHP يقرأ من أنبوب في وضع الحظر. giveacodicetagpre.

أود أن أكون قادرا على تنفيذ pcntl_signal_dispatch كل بضع ثوان بينما ينتظر البرنامج النصي مدخلات من الأنابيب، دون إزعاج قراءة الأنابيب في قائمة الانتظار.

أي اقتراحات؟

هل كانت مفيدة؟

المحلول

As far as I know, you can't respond to signals when the script is blocking. You'd have to either do non-blocking reads from your pipe or do the reads within one process and dispatch the signals in the other (read in the child and pass back to the parent via pipe, have parent respond to signals). If you were reading in the child and passing back to the parent via pipe, then you may not in fact need the signals.

Read this, it will make more sense (contains step-by-step code):

http://www.tuxradar.com/practicalphp/16/1/9

... and the overall parent page:

http://www.tuxradar.com/practicalphp/16/0/0

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top