in reply to Remotely Executing a background command
Use an inline thread:
use threads; ... my $pid :shared; my $tid = async{ ## Removed 'my' below. Thanks Jettero. $pid = system("ssh root@ip ./sleepwake (args) &"); $pid = 0; return $?; }; ... ## kill 2, $pid if $pid; ... unless( $pid ) my $result = $tid->join; ## do something; } ...
|
---|