Open melezhik opened 7 years ago
A further investigation.
Looks like function _keel_tees
can't waitpid - https://github.com/dagolden/Capture-Tiny/blob/master/lib/Capture/Tiny.pm#L286 and thus hangs forever :
These are the child (tees) processes can't be waited in parent process:
# invoking in parallel terminal when script hangs:
$ ps uax|grep perl | grep -v watch
vagrant 11078 0.0 0.1 37660 8084 pts/1 S+ 10:03 0:00 perl test.pl
vagrant 11079 0.0 0.0 23812 4380 pts/1 S+ 10:03 0:00 /home/vagrant/perl5/perlbrew/perls/perl-5.24.1/bin/perl -C0 -e use Fcntl; $SIG{HUP}=sub{exit}; if ( my $fn=shift ) { sysopen(my $fh, qq{$fn}, O_WRONLY|O_CREAT|O_EXCL) or die $!; print {$fh} $$; close $fh; } my $buf; while (sysread(STDIN, $buf, 2048)) { syswrite(STDOUT, $buf); syswrite(STDERR, $buf); } /tmp/oVVAM1Ixty
vagrant 11080 0.0 0.0 23812 4336 pts/1 S+ 10:03 0:00 /home/vagrant/perl5/perlbrew/perls/perl-5.24.1/bin/perl -C0 -e use Fcntl; $SIG{HUP}=sub{exit}; if ( my $fn=shift ) { sysopen(my $fh, qq{$fn}, O_WRONLY|O_CREAT|O_EXCL) or die $!; print {$fh} $$; close $fh; } my $buf; while (sysread(STDIN, $buf, 2048)) { syswrite(STDOUT, $buf); syswrite(STDERR, $buf); } /tmp/fo1UeJaVAo
# or in hierarchy mode:
$ ps fuax | grep perl
vagrant 11078 0.5 0.1 37660 8084 pts/1 S+ 10:03 0:00 | \_ perl test.pl
vagrant 11079 0.0 0.0 23812 4380 pts/1 S+ 10:03 0:00 | \_ /home/vagrant/perl5/perlbrew/perls/perl-5.24.1/bin/perl -C0 -e use Fcntl; $SIG{HUP}=sub{exit}; if ( my $fn=shift ) { sysopen(my $fh, qq{$fn}, O_WRONLY|O_CREAT|O_EXCL) or die $!; print {$fh} $$; close $fh; } my $buf; while (sysread(STDIN, $buf, 2048)) { syswrite(STDOUT, $buf); syswrite(STDERR, $buf); } /tmp/oVVAM1Ixty
vagrant 11080 0.0 0.0 23812 4336 pts/1 S+ 10:03 0:00 | \_ /home/vagrant/perl5/perlbrew/perls/perl-5.24.1/bin/perl -C0 -e use Fcntl; $SIG{HUP}=sub{exit}; if ( my $fn=shift ) { sysopen(my $fh, qq{$fn}, O_WRONLY|O_CREAT|O_EXCL) or die $!; print {$fh} $$; close $fh; } my $buf; while (sysread(STDIN, $buf, 2048)) { syswrite(STDOUT, $buf); syswrite(STDERR, $buf); } /tmp/fo1UeJaVAo
Killing those tee's processes in parallel console make script finished:
$ kill 11079 11080
Meanwhile I run cross issue against sshulte - https://github.com/sshuttle/sshuttle/issues/139
Hi! Here is test story:
Compare this with when runs test.bash directly:
Also there is thread started by me at PerlMonks which you may find useful http://perlmonks.org/?node_id=1185749 with regards to this issue.
Sshutle information could be found here - https://github.com/apenwarr/sshuttle , there is no any special about besides it probably demonizes improperly. However this could be considered as example of such a "bad" external programs which Capture::Tiny interacts whit by IPC and which make it hangs ... Anyway probably we need to investigate this more ...