Subject: kqueue: pipes and EOF
To: None <current-users@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: current-users
Date: 10/07/2004 19:25:17
--OgqxwSJOaUobr8KG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

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?

--=20
Christian

--OgqxwSJOaUobr8KG
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFBZXv90KQix3oyIMcRAusTAJ9IPzpwieAMIawPBd2z6n4bd/SY7QCePlGH
vfBD6vI/KI9Q0VZ0skunVlI=
=eFQ1
-----END PGP SIGNATURE-----

--OgqxwSJOaUobr8KG--