Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 12 Oct 2023 18:43:20 +0200
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: aio_close needed in dup2?

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.