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
In reply to Re: parent not waiting for child process
by stevieb
in thread parent not waiting for child process
by johnd2323
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |