in reply to Re: Catch loss of communication
in thread Catch loss of communication

then use select() to wait for something to happen and then check whether you can write, read or it's an error examining its output arguments.

There are two versions of select available, one from the core (see perlfunc) and the other, maybe easier to use, from IO::Select.