Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This works just fine but after the process terminates and waitpid returns a -1 indicating it has terminated I can't find any way to get the return code from original system command. The waitpid command returns -1 once it terminates regardless of whether it terminated gracefully or not. I've tried using $? but it just returns -1 and even if it didn't I'm not sure how it would distinguish between the multiple processes running in parallel that can be terminating at any time. Is there any way to retrieve the return code from the original system command, maybe by passing the PID? Is there a better way to do this that can both let me run multiple system commands in parallel on Windows and provide some error checking? Ultimately I just want to be able to output to the user which commands finished successfully and which errored. Thanks for any help and please let me know if you need any more information or if I've left anything out.my $pid = system(1,"cmd..."); do { $wait = waitpid($pid,WNOHANG); } while ($wait != -1);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting a return code from waitpid in Windows
by kschwab (Vicar) on Jan 20, 2014 at 17:59 UTC | |
by huskerben (Initiate) on Jan 20, 2014 at 18:15 UTC | |
by ikegami (Patriarch) on Jan 20, 2014 at 20:11 UTC | |
by huskerben (Initiate) on Jan 20, 2014 at 18:46 UTC |