# Program execution splits here: if ($kidPID=fork()) { # On return from fork, the parent is in this branch of the if statement do { # Keep checking for child process to end. (Probably ought to put in # a sleep so we don't just sit and pound the CPU while we're waiting) $kidPID = waitpid($kidPID, WNOHANG); } while $kidPID > 0; # Child is done now, so continue onwards } else { # On return from fork, the child process is in this branch exec($your_batch_file); }