http://www.perlmonks.org?node_id=1020875


in reply to Re^4: Perl 5.8.8 threads, clean exit
in thread Perl 5.8.8 threads, clean exit

I was looking at threads to solve this issue with a neat single script, to replace the bunch of KSH scripts I now have and that are to slow, but as it seems this is not possible. (with this old perl/threads module) To bad.

Actually, it is probably quite easy to solve using even that ancient perl; given enough information about what you are trying to do.

For example:

sub thread { ## spawn a process to run the first command my $pid = open SSH, '|-', 'ssh' or die $!; ## send the command print SSH 'the first command'; ## Sleep for a while sleep $timeout; ## if the process is still running if( kill 0, $pid ) { ## kill it kill 9, $pid; ## wait until it goes away sleep 1 while kill 0, $pid; ## Open a new ssh session $pid = open SSH, '|-', 'ssh' or die $!; } print SSH 'the second command'; close SSH; }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.
Social