473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

pcntl_fork() and apache , redirect to stdout

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???
Jul 3 '06 #1
0 1815

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yawnmoth | last post by:
php.net's docs on pcntl_fork aren't exactly clear on how to spawn multiple child processes... i tried something like this, but it didn't seem to work: <? $pid1 = pcntl_fork(); $pid2 =...
6
by: Tsai Li Ming | last post by:
Dear all, I have a problem with a redirecting stdout and stderr. I am a top level module and has no control over the imported modules that are making system calls such as os.system or popen2.* ....
1
by: Lisa Pearlson | last post by:
Hi, I wish to write a little server script. It receives binary data and sends it back. Communication goes back and forth, so using apache is not possible. My little script will be a shell...
3
by: cmarvel | last post by:
All: I have a script using php-cgi 4.3 module. The script attempts to use the pcntl_fork() call but gets the error message "call to undefined function: pcntl_fork()" instead. Anyone know what's...
10
by: Michael Gaab | last post by:
If I redirect stdout by using freopen("afile", "w", stdout); and then I closed stdout using, fclose(stdout), essentially I am just closing "afile". I have to reestablish what stdout originally...
4
by: Thomas | last post by:
I'm having some issues with forking and defunct children. This is my code: #!/usr/bin/php <?php $socket = stream_socket_server("tcp://0.0.0.0:8000", $errno, $errstr); /* * LISTEN FOR...
12
by: David T. Ashley | last post by:
I've noticed that some scripting languages (PHP, for example) have options to control whether the script can be terminated by the user clicking STOP on their browser (or similar mechanisms). How...
3
by: falloutphil | last post by:
Hi, First of all sorry for the double post - this is on the Python page too, but as far as I can see this is an Apache issue now. Mods - feel free to delete the similar titled posts from me on...
3
by: Alejandro | last post by:
Hi: I want to redirect stdout to a textctrl I have. From what I read in the wxpython documentation, I can use the wxLogTextCtrl class to do this. I am doing the following: class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.