php man page for pcntl_fork

Query: pcntl_fork

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

PCNTL_FORK(3)								 1							     PCNTL_FORK(3)

pcntl_fork - Forks the currently running process

SYNOPSIS
int pcntl_fork (void )
DESCRIPTION
The pcntl_fork(3) function creates a child process that differs from the parent process only in its PID and PPID. Please see your system's fork(2) man page for specific details as to how fork works on your system.
RETURN VALUES
On success, the PID of the child process is returned in the parent's thread of execution, and a 0 is returned in the child's thread of execution. On failure, a -1 will be returned in the parent's context, no child process will be created, and a PHP error is raised.
EXAMPLES
Example #1 pcntl_fork(3) example <?php $pid = pcntl_fork(); if ($pid == -1) { die('could not fork'); } else if ($pid) { // we are the parent pcntl_wait($status); //Protect against Zombie children } else { // we are the child } ?>
SEE ALSO
pcntl_waitpid(3), pcntl_signal(3), setproctitle(3). PHP Documentation Group PCNTL_FORK(3)
Related Man Pages
fork(2) - freebsd
vfork(2) - bsd
fork(2) - ultrix
fork(2) - netbsd
pcntl_wait(3) - php
Similar Topics in the Unix Linux Community
creating child process
Get pid
Parent forking
help with unix command exec1 in C
How to wait for a grand child to finish?