Keeping an eye on hung system calls..

Thomas Yandell tom at
Tue Jun 6 12:59:05 BST 2006

Toby Corkindale wrote:
> Both methods are kind of ugly though.. The system() call is expensive enough as
> it is (including it's own fork&exec), and I'd still need to find a mechanism to
> make sure I can kill the system-child of the worker fork-or-thread, as well as
> just the worker.
If the system call is already doing a fork and exec, then replacing it
with your own fork and exec shouldn't add much extra overhead. Then a
time-out of the child process is as simple as:

if (my $child = fork) {
  eval {
    local $SIG{CHLD} = sub {die};
    sleep 10;
  kill TERM => $child
    unless $@;
else {
  exec('mplayer ...');


More information about the mailing list