my $pid = open2($rfh, $wfh, "ssh $opts $hostspec $cmd"); #### ### Self-pipe init. pipe(SIGRD, SIGWR); # Make SIGRD non-blocking. vec($rin, fileno SIGRD, 1) = 1; #### my $byte = 1; syswrite(SIGWR, $byte, 1); #### my $nfound = select($rout = $rin, $wout = $win, undef, undef); # Check $nfound for errors. if(vec($rout, fileno SIGRD, 1)) { my $byte; while(sysread(SIGRD, $byte, 1)) { if($term) { # INT/TERM arrived, kill sshs, modify some data, ... $term = 0; } else { # CHLD arrived, do waitpid(), modify some data, ... } }