Re: About resource of popen
| From: | Fernando chucre | Date: | Wed, 02 May 2007 14:43:09 +0000 |
| Subject: | Re: About resource of popen | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254235@lists.php.net to get a copy of this message | ||
Somebody? help me!!
:D
2007/4/30, Fernando chucre <fernandochucre@gmail.com>:
Hello all, I make a script for read and interprete the stdout of cmd-- Fernando Chure PSL/CEip monitor. And I use signal_handler, the script is like this: <? declare(ticks = 1); pcntl_signal(SIGHUP,"sig_handler",false); $fh = popen('ip monitor','r'); while (!feof($fh)) {$line = fgets($fh); analize($line);} function analize($line) { ... } ; function sig_handler($signo) { ... }; ?> this script run in infine loop, or when to cmd 'ip monitor' exist. The script ever whait the next line of 'ip monitor', ever. Then when I send the signal SIGHUP to pid of script. In this point the instruction '$line = fgets($fh);' is aborted and return false to $line. The $fh is modified and the function feof($fh) return true and I have not access to $fh agaim. But the kid process 'ip monitor' is not kill. This is wanted? -- Fernando Chure PSL/CE