You shouldn't use print with select. Had you used sysrwite, I bet it would have returned "successfully wrote 0 bytes" (defined and == 0). In other words, the child had ended. (Well, technically, the child has closed its STDIN, but it did that when it ended.)
Try
my $msg = "msg\n"; foreach my $w (IO::Select->new($wh)->can_write()) { my $rv = syswrite($w, $msg, length($msg)); if (not defined $rv) { die("Unable to send data to child\n"); } if (not $rv) { warn("Child is no longer accepting input\n"); $w_sel->remove($w); next; } if ($rv != length($msg)) { warn("Pipe is full. We'd normally call select again\n"); next; } print "Successfully sent message to the child\n"; }
Don't forget to reap your children with waitpid.
In reply to Re: Pipes and IO::Select's method can_write()
by ikegami
in thread Pipes and IO::Select's method can_write()
by almut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |