http://qs321.pair.com?node_id=321108


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