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; } ...
In reply to Re: Remotely Executing a background command
by BrowserUk
in thread Remotely Executing a background command
by NolanPL
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |