sub ProcessPing { my ($Id, $IpAddr, $Command) = @_; $pingobject = Net::Ping->new(icmp,1); if ($child_pid = fork()) { #We must be the parent process return $child_pid; } elsif (defined $child_pid) { # We must be the child process $SIG{TERM} = \&int_handler ; #Since we are the child set up a #Signal handler. TERM was chosen #to try and eliminate memory consumption. while (1) { if ($pingobject->ping($IpAddr)) { print "Ping successfull to $IpAddr for Id $Id\n"; sleep 1; } else { print "Ping timeout occured on $IpAddr for Id $Id\n"; } } } } #### sub int_handler { #Only called by the child. print "Caught the signal!!!!!!!!!!!!!!\n"; my $signal = shift; die "Caught the signal, Exiting!!!\n"; }