system() with timeout
David Cantrell
david at cantrell.org.uk
Thu Apr 16 18:18:45 BST 2009
Anyone recommend a module to give me something like system(@list) but
with a timeout? My first attempt at writing it left processes hanging
around, which is Bad:
eval {
local $SIG{ALRM} = sub { die("Timed out\n"); };
alarm(5);
system(@list);
alarm(0);
};
The obvious solution is to fork/exec/kill but I'm lazy and would rather
someone else had already written it for me.
--
David Cantrell | Nth greatest programmer in the world
fdisk format reinstall, doo-dah, doo-dah;
fdisk format reinstall, it's the Windows way
More information about the london.pm
mailing list