mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: [musl] aio_close needed in dup2?
Date: Thu, 12 Oct 2023 18:43:20 +0200	[thread overview]
Message-ID: <ZSgiKLka+j6StpEm@voyager> (raw)

Hi all,

I noticed something today: In close(), we call __aio_close() to both
prevent AIO from using invalid file descriptors and implement the
requirement that outstanding AIO be cancelled. But in dup2() and dup3(),
that doesn't happen.

POSIX only says that dup2() closes newfd if it already is a valid file
descriptor. While not explicitly stated, I can't really find a sensible
interpretation of that requirement that is different from "as if by way
of close()". POSIX has no concept of closing file descriptors in any
other way. And dup3() is an extension function, but I think most
programmers will understand it to be an extension of dup2(), so the same
argument applies there.

So, do we need to call __aio_close() in dup2() and dup3()?

Ciao,
Markus

             reply	other threads:[~2023-10-12 16:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 16:43 Markus Wichmann [this message]
2023-10-12 17:43 ` Rich Felker
2023-10-12 23:40   ` Gabriel Ravier

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=ZSgiKLka+j6StpEm@voyager \
    --to=nullplan@gmx.net \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).