Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

waiting for a process to finish

Status
Not open for further replies.

jpasquini

Programmer
Joined
Apr 20, 2006
Messages
44
Location
US
Hi All,

Has anyone ever ran a program in the background with a system call:

$status = system ( "run_program&" );

and then wanted to know when it finished? I have looked at articles on fork, wait, and waitpid, many of these appear to be the same obscure paragraph repeated over and over, apparently copied and pasted.

I would assume something like:

$process_id = system ( "run_program&" );

if ( ! $process_id )
{
print "You're finished!"
}



Any use of fork() gives me gobs of errors, resource ID in failed request, etc. There must be an easy way to do this..................................
 
Code:
$process_id = system ( "run_program&" );

if ( $process_id )
{
     print "You're finished!"
}

system returns a value that is the exit status of the program, it's described in the system() function documentation:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top