summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-06-28 11:54:53 (GMT)
committerGitHub <noreply@github.com>2023-06-28 11:54:53 (GMT)
commit78cedf260725849a83a7149650268f715c27bbff (patch)
tree246a398e65281bdf2edd4a31520b102f936d498e /Python
parent7bdf2c16e6dc8dabfff3314b61b2db7b0e156dc3 (diff)
downloadcpython-78cedf260725849a83a7149650268f715c27bbff.zip
cpython-78cedf260725849a83a7149650268f715c27bbff.tar.gz
cpython-78cedf260725849a83a7149650268f715c27bbff.tar.bz2
[3.12] gh-106118: Add O_CLOEXEC preprocessor guard (GH-106120) (#106199)
(cherry picked from commit 6c60684bf5d34fae27a2f6a142ff794b38cefe1b) Co-authored-by: Erlend E. Aasland <erlend@python.org>
Diffstat (limited to 'Python')
-rw-r--r--Python/sysmodule.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index b8254f4..4bd38b4 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -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);