I was mainly just wondering why the can_write() method does essentially say "Yes, I can write", if it can't...
The underlying function is called select. can_write is a misnomer. It doesn't alert of the ability to write. It alerts the receipt of a write event. The inability to write is a write event.
you get exactly the same behaviour, if the child is still alive, but doesn't take input (as when explicitly having closed STDIN)
In both cases, the child explicitly closed STDIN. In both cases, the child is not (completely) dead. It only disappears after waitpid allows it to die.
why it can't figure out that there is some problem on the other end (or, at least, doesn't tell you)
But that's exactly what it does! select tells you there's an event, and syswrite tells you what the event is. It's convenient how you are saved from making a third system call.
Something else that might be of interest is knowing when a child becomes a zombie. I don't know if unix allows you to be alerted of such an event, but it can be determined by polling waitpid($pid, WNOHANG).
In reply to Re^5: Pipes and IO::Select's method can_write()
by ikegami
in thread Pipes and IO::Select's method can_write()
by almut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |