note 83753 deleted from function.proc-close by danbrown

From: Date: Tue, 17 May 2011 14:01:03 +0000
Subject: note 83753 deleted from function.proc-close by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179813@lists.php.net to get a copy of this message
Note Submitter: proc_close_at_php_net at mailfilter dot com dot ar ---- 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 }

« previous php.notes (#179813) next »