I am trying to run an application inside a Perl script using system(). The application I’m running gets stuck sometimes (it enters some kind of infinite loop). Is there a way I can know if this application is stuck and kill it to continue with the Perl script?
I’m trying to do something like this:
start testapp.exe;
if(stuck with testapp.exe) {
kill testapp.exe;
}
Determining if “it is stuck in infinite loop” is called Halting Problem and is undecidable.
If you want to kill it, you will have to fork the application using
forkand then kill it from the other fork, if it is going for too long.You can determine if the proccess is going for too long by this
at least, according to this manual page
I am not sure how well it works on various systems, you can try it out.
Not a direct answer, but I can recommend using
forksmodule if you want to fork with ease, but it works only on UNIX systems (not windows).OK, more helping code 🙂 It works in UNIX, according to perlfork perldoc, it should work on Windows exactly the same way.