Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: how can we tell when a background process is finished?

by dave_the_m (Monsignor)
on Jun 20, 2004 at 09:51 UTC ( [id://368260]=note: print w/replies, xml ) Need Help??


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");

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found