#!/usr/bin/perl -w use threads; use threads::shared; my $sshDone:shared; $sshDone=0; my $th=threads->create('test'); $th->join(); sleep 3; if (!$sshDone) { $th->kill('KILL'); print "Kill signal sent\n"; } sleep 2; sub test { $SIG{'KILL'} = sub { print "KILL THREAD\n"; threads->exit(); }; `ssh foo\@poker date`; $sshDone=1; }