Sure, lots of ways. For example instead of calling your program you could call a wrapper script that calls your program and on exit creates a file/appends to a file/touches a file. This can be detected by your script
#!/bin/sh
# wrapper script
program1
touch /tmp/finishedwith$1
You could call this from perl with a random number as parameter (the $1) so that each finish would create a different file. In the perl script you would monitor for the existance of this file
This is easy but not very clean and safe. Another way is to use fork instead of system, because fork tells you the process id of the newly created process. And you can wait() for the process to finish (which would block your script) or check if the process is still running (somehow ;-).
But really, look at Parallel::ForkManager, all the functions you want are already there. With "run_on_finish" you can choose a subroutine that is called when the process finishes.
|