質問

ブロックモードでパイプから読み取るPHPスクリプトを持っています。

while($input = trim(fgets($pipe))) { do some stuff }
.

スクリプトがパイプからの入力を待っていますが、キューに入れられたパイプが読み込まれずに、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