in reply to how can we tell when a background process is finished?

If we run system("program &");, is there a way to know when "program" has finished its execution?
No.
Instead, create a signal handler for SIGCHLD, then fork(), and do system("program") in the child.

Dave.

Replies are listed 'Best First'.
Re^2: how can we tell when a background process is finished?
by integral (Hermit) on Jun 20, 2004 at 10:39 UTC

    Or you can do exec("program") in the child, saving another process, since system() incorporates a fork+exec.

    --
    integral, resident of freenode's #perl
    
Re^2: how can we tell when a background process is finished?
by Anonymous Monk on Jun 20, 2004 at 11:34 UTC

    Thanks...do you know where I can find an example of this? I understand how to fork and then do system("program") in the child, but I'm not sure how to handle the "signal handler" for SIGCHLD. I think I will have to use waitpid()?

      Take a look at perlmonkey's MP3 server with IO::Socket tutorial.
      It explains in the fifth paragraph exactly what you're asking about processes.

      Best regards,

      my ($author_nickname, $author_email) = ("DaWolf","erabbott\@terra.com.br") if ($author_name eq "Er Galvão Abbott");