use strict; use warnings; [...] my $pid = fork; die "Failed to fork: $!\n" unless (defined $pid); unless ($pid) { exec '/path/to/program', 'argument'; die "Failed to exec: $!\n"; } [...] { local $SIG{CHLD} = 'IGNORE'; kill TERM => $pid or die "Failed to kill $pid: $!\n"; }