LOL. I know what an if else clause do. But in this case both should print. When fork is called the process divides in two processes. The first process is the parent and so it prints when IF clause(because $pid in this case will be the pid of the child so it's bigger thank zero. The second is the child so it prints when ELSE clause(the $pid in this process is 0). They both print, that program is a simple test to multiprocessing .
Anyway...
User Profile
Collapse
-
I'm sorry I'm kind of a new but what does this mean? In the browser only one of them writes but php in cli both write like when I used C. Is this a problem because of the browser. My idea was to open a new page, fork the process, terminate the parent and let the child live as a deamon in order to keep aquiring data from serial...Code:Rizladonovich Well, your control-flow does not allow more than one statement to be printed, as is correct.
Leave a comment:
-
pcntl_fork suport instaled but not working correctly
Greetings.
First of all I must apologyse for my english.
I have used multi processing before in C but know I have a project that it would be usefull to use it in php.
Here comes the problema I installed php support for pcntl_fork and when running a simple test program It does not work correctly.
...Code:$pid = pcntl_fork(); if ($pid != -1) { if ($pid) { print "In theLast edited by Niheel; Sep 18 '10, 10:31 PM.
No activity results to display
Show More
Leave a comment: