in reply to Submitting program to background from perl

You may want to use exec in place of system, to get the backgrounding, without needing to fork and all that other work.

Update: There are times when you'd want to fork (if you needed to get the final status from when the program finished), and I have no idea what the program is that you're kicking off. But the example given doesn't attempt to capture the return value from system(), and as you're attempting to run it through nohup, in the background, I can only assume that it's not needed.

Replies are listed 'Best First'.
Re: exec, not system
by gerry (Sexton) on Mar 03, 2005 at 19:33 UTC
    I think that I need to fork when using an exec so my perl process doesn't die. Doesn't an exec replace the current process? My perl module must run 24/7 to monitor the remote server program that also must run 24/7 and if the server program hangs, dies, or is unable to access it's database...my perl module must restart it in the background. That's the reason I was using the system call in the first place. Anyway, I am going to play around and see fi I can restruct it using a fork and exec. Thanks.