$SIG{CHLD}='IGNORE'; #... unless(fork()) { SIG{CHILD}='DEFAULT'; close(STDIN); close(STOUT); close(STERR); open(my $mailfh, '| /usr/sbin/sendmail -t -oi ') or exit(); print $mailfh 'From: test@example.org', "\n", 'To: admin@example.org', "\n", 'Subject: ERROR in blah blah', "\n", "\n", 'Error occured in ThisOrThat', "\n", "" . localtime(time), "\n", '.'; close($mailfh); exit(); }