in reply to parent not waiting for child process
The following seems to work for me... the test.bat script simply contains echo "inside batch script":
Update: added wait() call and associated output. Note that without wait(), child procs could become zombies. The call to wait() can be at the very bottom of the script, inside of a parent block.
use warnings; use strict; my $pid = fork(); if ($pid){ print "parent...\n"; } else { sleep 2; system "test.bat"; } if ($pid){ print "parent: doing stuff...\n"; } else { print "child: exiting\n"; } if ($pid){ print "parent: done doing stuff, waiting...\n"; wait; print "parent: children dead, safe to exit\n"; }
Output:
parent: doing stuff parent: done doing stuff, waiting... "inside batch script" child: exiting parent: children dead, safe to exit
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parent not waiting for child process
by BrowserUk (Patriarch) on Aug 02, 2016 at 19:15 UTC |