note 41244 added to function.proc-open

From: Date: Sun, 04 Apr 2004 03:14:12 +0000
Subject: note 41244 added to function.proc-open
Groups: php.notes 
Request: Send a blank email to php-notes+get-67602@lists.php.net to get a copy of this message
i used for multithreading i needed to ping large number of hosts i open all the process, then i read and close them. <?php //(...) part of the code for ($oo=$Dep; $oo<$var; $oo++) { // i open the process $var is the number of process $descriptorspec[$oo] = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "/tmp/error-output.txt", "a"), ); $ip = getip(....); // internal function make your own =) $process[$oo] = proc_open("ping -c 3 -w 20 $ip", $descriptorspec[$oo], $pipes[$oo]); } sleep(3); for ($oo2=$Dep2; $oo2<$var2; $oo2++) { if (is_resource($process[$oo2])) { while(!feof($pipes[$oo2][1])) { $cont[$oo2] .= fgets($pipes[$oo2][1] ); // i read the process output } fclose($pipes[$oo2][1]); $con[$oo2] = proc_close($process[$oo2]); // i close all one by one } } //(...) parf of the code ?> ---- Manual Page -- http://www.php.net/manual/en/function.proc-open.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41244 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41244&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41244&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67602) next »