Don't use readline (<>) on filehandles you pass to select.
It can block (which defies the purpose of using select), and it can hide waiting data from select (meaning select won't wake up even though data is waiting to be read).
should beforeach $handle1 (@read_from) { $buf = <$new_sock>; if($buf){ print $buf; } }
orforeach my $handle1 (@read_from) { my $buf = ''; my $rv = sysread($handle1, $buf, 64*1024, length($buf)); # Handle error if !defined($rv) # Handle eof if !$rv print $buf; # Whatever we got, including partial lines }
foreach my $handle1 (@read_from) { our $buf; local *buf = \( $buf{fileno($handle1)} ); # alias $buf = '' if !defined($buf); my $rv = sysread($handle1, $buf, 64*1024, length($buf)); # Handle error if !defined($rv) # Handle eof if !$rv while ($buf =~ s/^(.*\n)//) { print $1; # Full line at a time } }
Does that also fix the problem you are reporting?
In reply to Re: Fork is changing up my IO::Select behaviour
by ikegami
in thread Fork is changing up my IO::Select behaviour
by Workman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |