gcoates has asked for the wisdom of the Perl Monks concerning the following question:

Hi, monks. I need to write several perl CGI scripts that kick off another program, send some information to the browser, and then exit while the other program does its thing in the background. I looked at the exec and system functions, but it looks like these both wait for the called program to return before the parent program will continue or exit. Is there any way to do what I'm trying to do?

Replies are listed 'Best First'.
Re: Executing programs without waiting
by edoc (Chaplain) on Nov 22, 2005 at 21:45 UTC
    fork will let you do what you want to do..

    cheers,

    J

Re: Executing programs without waiting
by GrandFather (Saint) on Nov 22, 2005 at 21:46 UTC

    exec doesn't return to the "calling" program, so you could fork and exec to get that behaviour.


    DWIM is Perl's answer to Gödel

      Here's what I'm trying now:

      #!/usr/bin/perl
      
      $SIG{CHLD} = "IGNORE";
      fork();
      exec("perl set");

      Is this right? The first program still doesn't seem to continue until the child program finishes... What am I missing here?