Interesting! Thank you.
I will keep that in mind. I will first experiment with a simple $ssh->check_master
Let’s say that I created a master connection this way: my $ssh = Net::OpenSSH->new(...);
Before calling a slave ssh command with open3 or capture, I will test $ssh to check if it is still connected or not, like:
$ssh = Net::OpenSSH->new(...) unless ($ssh->check_master);
$ssh->capture(...);
I will see how light or heavy on CPU this check_master function is.
EDIT: no errors and the script works fine. Killed the ssh process on the remote device to test and...
The script works, but not as expected. Seems that an ssh connection is recreated allowing the slave command to be run, but there is no more master ssh connection sticking. After first disconnect event, it reconnects each time instead of staying connected like the first time.