note 83753 added to function.proc-close

From: Date: Tue, 10 Jun 2008 12:51:05 +0000
Subject: note 83753 added to function.proc-close
Groups: php.notes 
Request: Send a blank email to php-notes+get-140304@lists.php.net to get a copy of this message
In response to the problem mentioned by ashnazg at php dot net about --enable-sigchild masking the real exit status, this is how I tricked it (Linux): $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); $cmd = "dosomethingatshell"; // My hack: $cmd = "( $cmd ) 3>/dev/null ; echo \$? >&3"; $descriptorspec[3] = array("pipe","w"); // .... execute .... $res = proc_open($cmd, $descriptorspec, $pipes); if( is_resource($res) ) { ..... // Get the exit status for the original command $status = (int) str_replace("\n","",stream_get_contents($pipes[3])); foreach($pipes as $pipe) fclose($pipe); $n = proc_close($res); // $n is not useful; $status has the actual exit status // Notice that $status is not the termination status, // as proc_close() should return but only the *exit* status } ---- Server IP: 201.216.232.3 Probable Submitter: 200.69.238.3 ---- Manual Page -- http://www.php.net/manual/en/function.proc-close.php Edit -- https://master.php.net/note/edit/83753 Del: integrated -- https://master.php.net/note/delete/83753/integrated Del: useless -- https://master.php.net/note/delete/83753/useless Del: bad code -- https://master.php.net/note/delete/83753/bad+code Del: spam -- https://master.php.net/note/delete/83753/spam Del: non-english -- https://master.php.net/note/delete/83753/non-english Del: in docs -- https://master.php.net/note/delete/83753/in+docs Del: other reasons-- https://master.php.net/note/delete/83753 Reject -- https://master.php.net/note/reject/83753 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140304) next »