Friday, October 23, 2009

Forking in PHP on Mac OSX using pcntl_fork

1)sudo port selfupdate
2)sudo port update outdated
3)sudo port install php5-pcntl
4)Try the following example

$pid = pcntl_fork();

if($pid) {
// parent process runs what is here
print "parent\n";
}
else {
// child process runs what is here
print "child\n";
}
?>

2 comments:

prathap said...

This is not multi threading, a fork creates a new process - not a thread.

codeshepherd said...

ok, I will change the topic.