ehdonhon has asked for the wisdom of the Perl Monks concerning the following question:
I'm having one heck of a time getting this to work. I need to be able to have a perl script (running in a unix environment) start up some process in the background and then exit.
The problem I'm running into is that no matter what I do, either 1) Perl hangs and waits until the background process completes, or 2) The background process dies when perl dies.
So far, the only thing that I've found that actually works the way I want it to, is something like this:
This is followed up by a shell script like this:system('run_my_program.sh');
#!/bin/sh my_program &
That works great. Whenever it is the shell script that sticks the process in the background it runs just the way I want it to. However, a Perl command like this
does not. Using the perl fork() command also does not work. As soon as my main perl script dies, all of the children processes get reaped.system( "my_program &" );
I would imagine that if it is possible to have perl make a system call to a one line shell script that does what I want, that it must be possible to bypass the shell script all together and just make perl stick the process in the background on it's own. Any advice would really be appreciated.
|
|---|