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; } ...

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."