AlphaGrey has asked for the wisdom of the Perl Monks concerning the following question:
Next I tried with Win32::Process::Create, and it also exhibits the same problem...the parent doesn't "exit 0", until the child dies.if (my $ChildPid = fork) { # Parent - create lock and exit my $Lock = Childlck->new($ResName); $Lock->lock_mk($ChildPid); exit 0; } else { # Child - continue as G daemon exec $CMD, $CMDLineArgs, @ARGV; }
Then I tried using system() to create a new perl process, but it also doesn't return from the parent script until the child dies.Win32::Process::Create($ChildProc, $CMD, $CMDLine, 0, 0, $CWD) || +LOG_MSG("E", "Could not spawn child: $!", 52099); $ChildPID = $ChildProc->GetProcessID(); LOG_MSG("I", "ChildPID = $ChildPID", 52099, $ChildPID); my $Lock = Glck->new($ResName); $Lock->lock_mk($ChildPID); LOG_MSG("I", "Online.pl is about to exit with 0.", 52099); exit (0);
How can I create a process and have the parent process return while the child process continues running?system($CMDLine); my $Lock = Glck->new($ResName); LOG_MSG("I", "Online.pl is about to exit with 0.", 52099); exit (0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't get Win32::Create::Process() parent to exit before it's children
by BrowserUk (Patriarch) on Jan 20, 2010 at 01:39 UTC | |
by AlphaGrey (Initiate) on Jan 21, 2010 at 08:30 UTC | |
by Anonymous Monk on Oct 15, 2010 at 19:10 UTC | |
|
Re: Can't get Win32::Create::Process() parent to exit before it's children
by ikegami (Patriarch) on Jan 20, 2010 at 05:00 UTC | |
by AlphaGrey (Initiate) on Jan 21, 2010 at 08:40 UTC | |
|
Re: Can't get Win32::Create::Process() parent to exit before it's children
by cdarke (Prior) on Jan 20, 2010 at 06:42 UTC |