Re: Bug#584538: libdebian-installer: problems on Hurd with poll()
Hello,
Jérémie Koenig, le Fri 04 Jun 2010 14:41:34 +0200, a écrit :
> On Hurd, libdebian-installer gets stuck inside the internal_di_exec()
> function. This is caused by the way poll() reports end-of-file, which
> cannot be portably relied on.
>
> The attach patch uses feof() instead of POLLHUP to detect it.
> Index: packages/libdebian-installer/src/exec.c
> ===================================================================
> --- packages/libdebian-installer/src/exec.c (revision 63370)
> +++ packages/libdebian-installer/src/exec.c (working copy)
> @@ -162,14 +162,12 @@
> {
> bool exit = false;
>
> + /* Implementations of poll() deliver various combinations of POLLIN and
> + POLLHUP on EOF. fgets() detects it and we check with feof() below.
> + References: http://www.greenend.org.uk/rjk/2001/06/poll.html */
> for (i = 0; i < pipes; i++)
> {
> -/* References: http://www.greenend.org.uk/rjk/2001/06/poll.html */
> -#if defined(__FreeBSD_kernel__)
> - if ((pollfds[i].revents & POLLIN) && (! (pollfds[i].revents & POLLHUP)))
> -#else
> - if (pollfds[i].revents & POLLIN)
> -#endif
> + if (pollfds[i].revents & (POLLIN | POLLHUP))
> {
> while (fgets (line, sizeof (line), files[i].file) != NULL)
> {
> @@ -180,8 +178,8 @@
> len--;
> }
> files[i].handler (line, len, io_user_data);
> + exit = true;
> }
> - exit = true;
> }
> }
>
> @@ -189,7 +187,7 @@
> continue;
>
> for (i = 0; i < pipes; i++)
> - if (pollfds[i].revents & POLLHUP)
> + if (feof(files[i].file))
> exit = true;
>
> if (exit)
This seems simpler to me. Could BSD people check they do not have bad
effects?
Samuel
Reply to: