bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fcntl-h: define O_CLOEXEC and O_EXEC if not defined; use new


From: Jim Meyering
Subject: Re: [PATCH] fcntl-h: define O_CLOEXEC and O_EXEC if not defined; use new defines
Date: Fri, 10 Sep 2010 21:13:34 +0200

Paul Eggert wrote:
> The motivation for this is that I'm putting GNU tar on a file-descriptor
> diet, and I needed O_CLOEXEC, which gnulib sometimes doesn't define.
> It's more convenient for tar if gnulib defines O_CLOEXEC to 0 on platforms
> that lack it, which is what gnulib already does for the other O_* flags.
>
> This patch also adds O_EXEC.  GNU tar doesn't need that, but might as well
> add it while I'm in the neighborhood.
>
> * doc/posix-headers/fcntl.texi (fcntl.h): Document that
> O_CLOEXEC is now defined to 0 if it is not defined, like other flags.
> Also, O_EXEC is now defined to be O_RDONLY if O_EXEC is not defined.
> Similarly for O_SEARCH; this last was already true, but not documented.
> * lib/fcntl.in.h (O_CLOEXEC): Define to 0 if not defined.
> * lib/dup-safer-flag.c (O_CLOEXEC): Remove now-useless #define.
> * lib/dup3.c, lib/pipe2.c, tests/test-dup-safer.c, tests/test-fcntl.c:
> Likewise.
> * lib/popen-safer.c (open_noinherit): Check whether O_CLOEXEC
> is zero, not whether it is defined.
> * tests/test-dup3.c, tests/test-pipe2.c (main): Likewise.
> * lib/progreloc.c (find_executable): Use O_EXEC rather than O_RDONLY.
> * lib/open.c (open): Check for O_SEARCH as well as for O_RDONLY.

Hi Paul,

More convenient for tar, but possible silent inconvenience/bugs
in gnulib clients.  Any client that does the following may end
up leaking file descriptors:

#ifdef O_CLOEXEC
... expect that O_CLOEXEC works...
#else
workaround
#endif

I've checked a few projects, and found none like that, so maybe there's
no actual trouble, but it does deserve a mention in NEWS.  A few projects
may well end up making similar changes:

  -#ifdef O_CLOEXEC
  +#if O_CLOEXEC



reply via email to

[Prev in Thread] Current Thread [Next in Thread]