Skip to content

Instantly share code, notes, and snippets.

@phil-lavin
Created June 19, 2014 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phil-lavin/58531341fa271051cf90 to your computer and use it in GitHub Desktop.
Save phil-lavin/58531341fa271051cf90 to your computer and use it in GitHub Desktop.
<?php

$pid = pcntl_fork();

if ($pid == -1) {
     die('could not fork');
} else if ($pid) {
        cli_set_process_title("parent");
} else {
        cli_set_process_title("child");
}

sleep(30);
?>
[phil@linux queue]$ ps aux | grep -i 'parent\|child' | grep -v grep
root     19838  0.6  0.1 257784 23148 pts/2    S+   19:42   0:00 parent
root     19839  0.0  0.1 257784 16936 pts/2    S+   19:42   0:00 child
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment