Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My problem is that the perl script never really ends. I've tried threads, fork, and whatnot, but there is always some zombie or defunct process, or just keeps running in 'ps'.
Normally this shouldn't be a problem... I can afford a little stray process every now and then... But this script needs to be executed via cgi, and if it doesn't end "gracefully", the server never sends the reply to the client.
This is the best I've done so far (without warnings and ignoring errors, just the main stuff):
#!/usr/bin/perl $SIG{CHLD} = 'IGNORE'; open STDIN, '/dev/null/'; open STDOUT, '>/dev/null/'; open STDERR, '>/dev/null/'; exit if fork(); chdir '../working/dir'; system './program &';
Any advice is greatle appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: run a background process
by merlyn (Sage) on Jul 14, 2005 at 11:04 UTC | |
by Anonymous Monk on Jul 14, 2005 at 23:53 UTC | |
|
Re: run a background process
by blazar (Canon) on Jul 14, 2005 at 10:02 UTC | |
by Anonymous Monk on Jul 14, 2005 at 10:33 UTC | |
by blazar (Canon) on Jul 14, 2005 at 10:39 UTC | |
by Anonymous Monk on Jul 15, 2005 at 00:28 UTC | |
by blazar (Canon) on Jul 15, 2005 at 07:47 UTC | |
| |
|
Re: run a background process
by anonymized user 468275 (Curate) on Jul 14, 2005 at 12:05 UTC |