note 49299 added to ref.exec
| From: | louisdotjdotscorasatgmaildotcom at osu1 dot php dot net | Date: | Sun, 23 Jan 2005 18:43:43 +0000 |
| Subject: | note 49299 added to ref.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83819@lists.php.net to get a copy of this message | ||
To start a process to run in the background, you can use the same technique you would in writing a
daemon. Fork a new child while exiting in the parent, then set that as the process leader.
Finally, fork once more, and run whatever the command is:
<?php
if(pcntl_fork()) {
exit;
}
posix_setsid();
if(pcntl_fork()) {
exit;
}
pcntl_exec('/usr/bin/ogg123', array('-q', $this->findPath()));
?>
Of course, this would be the last thing that your script does, because the parent exits when you
spawn the new process. You could do more fancy things, but this works as a good starting point.
----
Manual Page -- http://www.php.net/manual/en/ref.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49299
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49299&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49299&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49299&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49299&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49299&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49299&report=yes
Search -- http://master.php.net/manage/user-notes.php