Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #19246

Re: proc_open, proc_get_status, proc_close

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.php
Subject Re: proc_open, proc_get_status, proc_close
Date 2023-01-06 09:07 -0500
Organization Aioe.org NNTP Server
Message-ID <tp99vj$14t$1@gioia.aioe.org> (permalink)
References <20230106112959.738fadea@gargantua.manuelito.lan>

Show all headers | View raw


On 1/6/2023 5:29 AM, Badarbo wrote:
> 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?

When I read:

last comment in https://www.php.net/manual/en/function.proc-close.php

second comment in https://www.php.net/manual/en/function.proc-get-status.php

then one could get the idea that proc_get_status take the status
code for $pstat['exitcode'] and proc_close after that return -1.

Arne




Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

proc_open, proc_get_status, proc_close Badarbo <badarbo@TOGLITUTTELEMAIUSCOLEhotmail.it> - 2023-01-06 11:29 +0100
  Re: proc_open, proc_get_status, proc_close Arne Vajhøj <arne@vajhoej.dk> - 2023-01-06 09:07 -0500
  Re: proc_open, proc_get_status, proc_close "J.O. Aho" <user@example.net> - 2023-01-06 17:35 +0100
  Re: proc_open, proc_get_status, proc_close Arno Welzel <usenet@arnowelzel.de> - 2023-01-07 16:05 +0100
  Re: proc_open, proc_get_status, proc_close Ezimene nimi Teine nimi <techfan55555@hotmail.com> - 2023-03-06 03:25 -0800
    Re: proc_open, proc_get_status, proc_close The Doctor <doctor@doctor.nl2k.ab.ca> - 2023-03-06 16:22 +0000
  Re: proc_open, proc_get_status, proc_close V õ l u r <yefap33237@cutefier.com> - 2023-05-25 05:40 -0700

csiph-web