in reply to Run a batch file and wait for it to finish

rezelle008:

Try using fork and waitpid in addition to exec. It should be something like:

# Program execution splits here: if ($kidPID=fork()) { # On return from fork, the parent is in this branch of the if stat +ement do { # Keep checking for child process to end. (Probably ought to +put in # a sleep so we don't just sit and pound the CPU while we're w +aiting) $kidPID = waitpid($kidPID, WNOHANG); } while $kidPID > 0; # Child is done now, so continue onwards } else { # On return from fork, the child process is in this branch exec($your_batch_file); }

Note: I've not done this, nor tested the above code, but it should be pretty close. Also, you may want to modify the logic a bit so that you don't hang the GUI thread. Instead, you could display a timer showing how long the process has been running, and if you want to get fancy, you could even provide a button to terminate the batch job or some such.

...roboticus

When your only tool is a hammer, all problems look like your thumb.