Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Run and kill external programm after x seconds

by eyepopslikeamosquito (Archbishop)
on Nov 23, 2016 at 08:01 UTC ( [id://1176383] : note . print w/replies, xml ) Need Help??

in reply to Run and kill external programm after x seconds

If your requirement is Windows only, using the Win32::Job module (a thin wrapper around Win32 Job objects) may make your code simpler and easier to understand.

In Win32::Job spawn() method you can control stdin/stdout/stderr, while its run() method provides a simple way to run programs with a time limit. Another useful feature is that killing a job kills that process and all sub-processes spawned by it (similar to Unix process groups).

Sample code can be found at Re: Timing Windows commands.