Re: proc_open, proc_get_status, proc_close

Ezimene nimi Teine nimi <[email protected]> Mon, 6 Mar 2023 03:25:44 -0800 (PST)
Newsgroups comp.lang.php
Message-ID <[email protected]>
Get to: http://aaaaaaaaaaaaaaaar.medianewsonline.com/firstpage.php

And invite all Your friends too !!!!!!!!!!!




On Friday, January 6, 2023 at 12:30:08 PM UTC+2, Badarbo wrote:
> 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?