in reply to How do you launch a background process and get pid?
Apart from that, you should be aware that the "exit" statement in your "if" block is never reached -- as stated in the perlfunc manpage, the "exec" call never returns.
If you remove both backgrounding and redirection from the command line string, your parent perl process will get the pid for the child sleep process, because "exec" won't have to invoke a shell to run the command -- i.e. you could do either this:
or this:exec( "sleep 30" );
exec( "sleep", "30" );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do you launch a background process and get pid?
by bt101 (Acolyte) on Apr 18, 2016 at 16:33 UTC | |
by afoken (Chancellor) on Apr 18, 2016 at 17:12 UTC |