Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: http waits on process

by etcshadow (Priest)
on Jan 13, 2004 at 20:57 UTC ( #321108=note: print w/replies, xml ) Need Help??

in reply to http waits on process

The problem is that when you call
`$myscript &`;
You are essentially calling
`sh -c '$myscript &'`;
In other words... you are waiting for the shell process to terminate... but the shell process (if it were interactive) would have returned a prompt imediately after firing off $myScript.

If you really want to fire off a background job from a perl process, and don't care about the output (btw: backticks imply that you do care about the output, but continuing imediately imply that you do not care about the output)... then you should do something more like this:

my $pid = fork; die "Could not fork: $!" unless defined $pid; if (!$pid) { exec $myScript; }
Which is somewhat akin to what the shell does when you launch the program foo by typing:
[user@host]$ foo &
------------ :Wq Not an editor command: Wq

Replies are listed 'Best First'.
Re: Re: http waits on process
by hotshot (Prior) on Jan 14, 2004 at 08:03 UTC
    As I said, the problem happened only when I did it from cgi script through the web page, when I tried it from a regular script, I had no problem.
    Additionally, I already tried the solution you suggested (fork and exec), and still I get the same problem, I think it something related to apache that waits for stdout or someting (closing stdout, didn't work also).
    Do you have another idea?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2023-06-07 02:15 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.