Connecting Tech Pros Worldwide Forums | Help | Site Map

pcntl_fork() and apache , redirect to stdout

David
Guest
 
Posts: n/a
#1: Jul 3 '06
Hello,
I'm trying to run a system call('ls' in this simple case) that is taking
quite a long. I would like to fork the system call into a child process
and waits display the output of the call while it is running.

Here is a piece of code:

$pid = pcntl_fork();

for ($i = 1; $i <= 5; ++$i) {
$pid = pcntl_fork();

if (!$pid) {
$query = "ls /tmp";
system ($query,$ret_val);
print "In child $i\n";
exit;
}
}

How can i make this script dynamic in my web page. Meaning how can i
print each loop while the child process is running in Apache and
redirect to STDOUT in the webpage???

Closed Thread