[ruby-core:120940] [Ruby master Bug#21128] dir.c defines O_CLOEXEC before it is defined by the system.
From:
"collinfunk (Collin Funk) via ruby-core" <ruby-core@...>
Date:
2025-02-12 05:06:49 UTC
List:
ruby-core #120940
Issue #21128 has been reported by collinfunk (Collin Funk).
----------------------------------------
Bug #21128: dir.c defines O_CLOEXEC before it is defined by the system.
https://bugs.ruby-lang.org/issues/21128
* Author: collinfunk (Collin Funk)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Building from master commit hash bfcf36fe2243d34a01b5707754be9164849150c9 on GNU/Linux, I see:
```
compiling dir.c
In file included from /usr/include/bits/fcntl.h:61,
from /usr/include/fcntl.h:35,
from dir.c:39:
/usr/include/bits/fcntl-linux.h:144:10: warning: "O_CLOEXEC" redefined
144 | # define O_CLOEXEC __O_CLOEXEC /* Set close_on_exec. */
| ^~~~~~~~~
dir.c:26:11: note: this is the location of the previous definition
26 | # define O_CLOEXEC 0
| ^~~~~~~~~
```
This is because the file includes unistd.h before falling back to 0 for O_CLOEXEC. But glibc requires inclusion of fcntl.h for O_CLOEXEC. Since that file is included after, it is redefined.
The C standard leaves the behavior of redefining a variable undefined and it is a simple fix, so I will create a pull request.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/