note 73295 deleted from function.posix-setsid by nlopess
| From: | nlopess@php.net | Date: | Fri, 16 Feb 2007 15:25:21 +0000 |
| Subject: | note 73295 deleted from function.posix-setsid by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123485@lists.php.net to get a copy of this message | ||
Note Submitter: roberto at spadim dot com dot br
----
when using pcntl_fork() function and running php with
php file.php &
if you get high cpu usage running exit from bash shell, you should try
<?php
$pid=pcntl_fork();
if ($pid==-1) die('couldn't fork');
elseif($pid==0){
posix_setsid();
//forked process (use posix_setsid() after forking on every new childs, since stdout can have
problems without mutex control)
}else{
//main script
}
?>