#!/usr/bin/perl -w use strict; my $sshpid = fork(); defined($sshpid) or die "fork error: $!"; if ($sshpid) { print "Parent PID is $$\n"; # Parent $SIG{HUP} = sub { warn "Aborting ssh pid $sshpid\n"; kill 'ABRT', $sshpid; exit(1); }; wait; exit(0); } else { # Child exec '/bin/sleep 6' or die "exec error: $!"; }