in reply to Background Process
print $reply_to_user; die "cannot fork: $!" unless defined ( my $pid = fork() ); if ( $pid ) { #this is the parent. exit; } else { #this is the child open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!"; sleep( 10 ); #do stuff }
 
update: thanks, Randal. ( btw, you don't have to plug your column each post, you're already famous. ;)
Additional update:Intrepid: I left STDERR alone because it should be connected to the web server error log, which is probably where you want the errors from a CGI.
ncw: Well, I am certainly a lover of doing it the easy way! :) Thanks for that, I've been using a home rolled Daemon module, but I see that I don't need to. But, is this a daemon? Proc::Daemon seems to close STDERR, so then we have to reopen it somehow to get the errors back into the webserver logs where we need them.
Paris Sinclair | 4a75737420416e6f74686572 pariss@efn.org | 205065726c204861636b6572 I wear my Geek Code on my finger.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Background Process
by merlyn (Sage) on Jun 26, 2000 at 02:42 UTC | |
by ncw (Friar) on Jun 27, 2000 at 00:19 UTC | |
by Anonymous Monk on Mar 28, 2002 at 21:40 UTC | |
|
RE: Re: Background Process
by Intrepid (Curate) on Jun 26, 2000 at 09:22 UTC |