my $pid = fork; if ($pid) { # do all the other tasks here system "kill $pid"; # ready to stop the polling } else { # do the polling }