tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Detecting parent's termination

On Tue, Jan 31, 2012 at 11:54:28AM +0100, Emmanuel Dreyfus wrote:

> Emmanuel Dreyfus <> wrote:
> > > You can use EVFILT_PROC with NOTE_EXIT for this purpose.
> > Is there any way to get a signal delivered? That happens in perfused,
> > which i linked with libpuffs, which IIRC is not thread-safe.
> I discovered a possible easier way: perfused shares a socketpair with
> the parent (that is, the filesystem), and it uses send/recv to talk with
> it. I just noticed I used MSG_NOSIGNAL here. As I understand, if I
> remove MSG_NOSIGNAL, I should get a SIGPIPE when parent dies. 
> Unfortunately I do not get any signal. I understand that is wrong, and I
> suspect it may be a SOCK_SEQPACKET bug.

You should only receive a SIGPIPE when you try to write to the
socket.  To detect that the other end of the socket has been closed,
you should poll for read and read will return zero.  If you need
async notification, turn on SIGIO for the socket which should be
delivered when the socket becomes readable in which case you can
poll for read and check that the return value is zero.

    Roland Dowdeswell                      http://Imrryr.ORG/~elric/

Home | Main Index | Thread Index | Old Index