Subject: kqueue: pipes and EOF
To: None <current-users@NetBSD.org>
From: Christian Biere <email@example.com>
Date: 10/07/2004 19:25:17
Content-Type: text/plain; charset=us-ascii
I often use a DNS helper process to circument the blocking gethostname()
and use two pipes to let the processes communicate. I've now modified my
program to use kqueue() instead of poll() if supported. I've noticed a
semantic difference between kqueue() and poll() with respect to pipes
which cannot be wrapped properly, unless I'm missing something. My program
doesn't monitor whether the child or the parent dies but instead relies on
poll() to set POLLHUP for the pipe descriptor (both processes are always
polling for readability) if one of the processes dies. This works fine.
However, doing the equivalent with kqueue() doesn't cause any event if
one of the processes dies so that the other one will wait forever.
Well, of course, there are workarounds like (still) using poll()
periodically on the pipe descriptor or - what I prefer - using
kqueue() with EVFILT_PROC and waiting for NOTE_EXIT. Though, this is
completely unnecessary when using poll(), so I cannot directly wrap
this but rather have to make this a NOP when using poll().
Is there any reason why kqueue() doesn't return a EVFILT_READ event
with EV_EOF set in this case or is this a bug?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)
-----END PGP SIGNATURE-----