]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-106118: Add O_CLOEXEC preprocessor guard (GH-106120) (#106199)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 28 Jun 2023 11:54:53 +0000 (04:54 -0700)
committerGitHub <noreply@github.com>
Wed, 28 Jun 2023 11:54:53 +0000 (11:54 +0000)
(cherry picked from commit 6c60684bf5d34fae27a2f6a142ff794b38cefe1b)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst [new file with mode: 0644]
Python/sysmodule.c

diff --git a/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst b/Misc/NEWS.d/next/Build/2023-06-26-21-56-29.gh-issue-106118.0cCfhl.rst
new file mode 100644 (file)
index 0000000..f93cae5
--- /dev/null
@@ -0,0 +1,2 @@
+Fix compilation for platforms without :data:`!O_CLOEXEC`. The issue was
+introduced with Python 3.12b1 in :gh:`103295`. Patch by Erlend Aasland.
index b8254f4e94fd0f743549adcd902a2dacee69a97c..4bd38b4b267873fa4f86725342d413acf2260fec 100644 (file)
@@ -2277,7 +2277,10 @@ PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void) {
     char filename[100];
     pid_t pid = getpid();
     // Use nofollow flag to prevent symlink attacks.
-    int flags = O_WRONLY | O_CREAT | O_APPEND | O_NOFOLLOW | O_CLOEXEC;
+    int flags = O_WRONLY | O_CREAT | O_APPEND | O_NOFOLLOW;
+#ifdef O_CLOEXEC
+    flags |= O_CLOEXEC;
+#endif
     snprintf(filename, sizeof(filename) - 1, "/tmp/perf-%jd.map",
                 (intmax_t)pid);
     int fd = open(filename, flags, 0600);