Skip to content

Instantly share code, notes, and snippets.

@a2ikm
Last active October 17, 2016 16:10
Show Gist options
  • Select an option

  • Save a2ikm/4f61ad421992fb9fb740ec90cbeb8873 to your computer and use it in GitHub Desktop.

Select an option

Save a2ikm/4f61ad421992fb9fb740ec90cbeb8873 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl -w
use strict;
$SIG{"CHLD"} = sub { exit; };
my $pid = fork();
if ($pid) {
foreach my $sig (qw(TERM INT QUIT)) {
$SIG{$sig} = sub {
kill $sig, $pid;
};
}
waitpid($pid, 0);
} else {
exec "long long command";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment