in reply to Re: CGI - run script without waiting
in thread CGI - run script without waiting
What you probably want to do, is fork off the desired script, with SIG(CHLD) ignored, so it won't wait. Then, you close STDOUT and other filehandles in your cgi script, and the web server should close it off.
or this simpler example:
#!/usr/bin/perl use warnings; use strict; $| = 1; # need either this or to explicitly flush stdout, etc. # before forking print "Content-type: text/plain\n\n"; print "Going to start the fork now\n"; if ( !defined(my $pid = fork())) { print STDERR "fork error\n"; exit(1); } elsif ($pid == 0) { # child close(STDOUT);close(STDIN);close(STDERR); exec('./fork-long-process-test-process'); # lengthy processing } else { # parent print "forked child \$pid= $pid\n"; exit 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: CGI - run script without waiting
by Yaerox (Scribe) on Apr 15, 2014 at 15:59 UTC | |
|
Re^3: CGI - run script without waiting
by Yaerox (Scribe) on Apr 16, 2014 at 08:59 UTC |