proc_open, proc_get_status, proc_close

Badarbo <[email protected]>
Newsgroups comp.lang.php
Organization Aioe.org NNTP Server
Message-ID <[email protected]>
Hello,
with the code below, $rv is 0 :-)

--- begin code ---
$pdesc=[0=>['pipe','r'],1=>['file','stdout.log','w'],2=>['file','stderr.log','w']];
$proc=proc_open('sleep 3',$pdesc,$pipes);
fclose($pipes[0]);
$rv=proc_close($proc);
echo('rv: '.$rv.PHP_EOL);
exit(0);
--- end code ---

With the code below, $rv is -1 :-(

--- begin code ---
$pdesc=[0=>['pipe','r'],1=>['file','stdout.log','w'],2=>['file',stderr.log','w']];
$proc=proc_open('sleep 3',$pdesc,$pipes);
$done=false;
while ($done===false) {
	$pstat=proc_get_status($proc);
	if (!$pstat['running']) $done=true;
	usleep(500000);
}
fclose($pipes[0]);
$rv=proc_close($proc);
echo('rv: '.$rv.PHP_EOL);
exit(0);
--- end code ---

Why oh why?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.