in reply to Detect whether a writeable filehandle has closed?

If you ignore SIGPIPE ($SIG{PIPE} = 'IGNORE';), the write will result in error EPIPE instead.

But it sounds like you really want to detect the child exiting. Add a $SIG{CHLD} handler.