in reply to How to detect dead socket
our $PARENT_ALIVE = 1; $SIG{PIPE} = sub { $PARENT_ALIVE = 0 }; [...] $unix_sock->print($message) if $PARENT_ALIVE; if (! $PARENT_ALIVE) { print "note: parent died; will not attempt future messages.\n"; }
It's been a while since I actually did this kind of thing, though, and this is untested!
(You can also subclass IO::Socket::UNIX and override print to wrap this safety check for you, if you want.)
|
|---|