Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: CGI and System

by eclark (Scribe)
on Feb 18, 2005 at 22:01 UTC ( [id://432538]=note: print w/replies, xml ) Need Help??


in reply to CGI and System

Wrap your head around this. It forks away from the cgi, detaches the child process and execs your command. If you're just running a perl script, you can replace the system call with a function you want to run in the background.

use strict; use POSIX 'setsid'; my $command = q{perl -e 'sleep 30'}; if (my $pid = fork) { exit; } elsif (defined $pid) { open STDIN, '/dev/null'; open STDOUT, '>/dev/null'; open STDERR, '>/dev/null'; setsid(); unless (exec $command) { die "Couldn't run process!"; } } else { die "Cannot fork: $!"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://432538]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-18 22:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found