All of lore.kernel.org
 help / color / mirror / Atom feed
From: "J.H. vd Water" <henri.van.de.water@xs4all.nl>
To: Alejandro Colomar <alx.manpages@gmail.com>,
	linux-man <linux-man@vger.kernel.org>
Cc: Ken Brown <kbrown@cornell.edu>,
	Michael Kerrisk <mtk.manpages@gmail.com>,
	"Michael T. Kerrisk" <mtk@man7.org>
Subject: Re: Simple changes to select(2) and pipe(7)
Date: Thu, 1 Dec 2022 15:39:12 +0100	[thread overview]
Message-ID: <724c2a0a-7c20-3a99-b868-4a9ba27310f7@xs4all.nl> (raw)
In-Reply-To: <a36590b4-a5fe-523c-f2bd-8af5c25f28a8@xs4all.nl>

Hi Alex,

Additional information:

LPI 63.2.3 Comparison of select() and poll():

Implementation details

"Within the Linux kernel, select() and poll() both employ the same set of
 kernel-internal poll routines ..."

See also: https://github.com/torvalds/linux/blob/master/fs/select.c

Furthermore:

 - https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html

DESCRIPTION
...
  POLLHUP
    A device has been disconnected, or a pipe or FIFO has been closed by the last process
    that had it open for writing. ...
...
RATIONALE

  The POLLHUP event does not occur for FIFOs just because the FIFO is not open for writing.
  It only occurs when the FIFO is closed by the last writer and persists until some process
  opens the FIFO for writing or until all read-only file descriptors for the FIFO are closed.

Next I decided to verify this on Linux (Fedora 35): poll(2) returns zero (after time out) on
a FIFO of which the write end is closed from the start ...,

meaning neither POLLIN nor POLLHUP have been set in revents.

Bottom-line: select(2) blocks on a FIFO of which the write end is closed from
the start (i.e. select.2 is wrong, or at least not complete).

Regards,
Henri

      reply	other threads:[~2022-12-01 14:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <30847211-efc7-12be-6ce9-c5c4ada16805@xs4all.nl>
2022-11-09 13:57 ` Fwd: Simple changes to select(2) and pipe(7) - example program Alejandro Colomar
2022-11-09 14:02   ` Alejandro Colomar
2022-11-09 14:04     ` Alejandro Colomar
2022-11-09 14:04       ` Alejandro Colomar
2022-11-09 14:15   ` Alejandro Colomar
2022-11-09 15:06     ` J.H. vd Water
2022-11-09 15:32       ` J.H. vd Water
2022-11-22 12:22       ` Simple changes to select(2) and pipe(7) J.H. vd Water
2022-11-22 12:25         ` J.H. vd Water
2022-12-01 14:39           ` J.H. vd Water [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=724c2a0a-7c20-3a99-b868-4a9ba27310f7@xs4all.nl \
    --to=henri.van.de.water@xs4all.nl \
    --cc=alx.manpages@gmail.com \
    --cc=kbrown@cornell.edu \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=mtk@man7.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.