]> Savannah Git Hosting - gnulib.git/commitdiff
get_ppid_of: Make more robust in multithreaded applications.
authorBruno Haible <bruno@clisp.org>
Wed, 27 May 2020 17:41:38 +0000 (19:41 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 28 May 2020 19:39:55 +0000 (21:39 +0200)
* lib/get_ppid_of.c (get_ppid_of): Pass an O_CLOEXEC flag to open().
* modules/get_ppid_of (Depends-on): Add 'open'.

ChangeLog
lib/get_ppid_of.c
modules/get_ppid_of

index beba581e904003fcca14887b18a7509dbf84c680..ae1df5ec7e236526fc677f8ba8ac3f376d94367c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-28  Bruno Haible  <bruno@clisp.org>
+
+       get_ppid_of: Make more robust in multithreaded applications.
+       * lib/get_ppid_of.c (get_ppid_of): Pass an O_CLOEXEC flag to open().
+       * modules/get_ppid_of (Depends-on): Add 'open'.
+
 2020-05-28  Bruno Haible  <bruno@clisp.org>
 
        get-rusage-as: Make more robust in multithreaded applications.
index 1560e7d84ba2e407811d89bc47ec2be567a9d46b..5579cd9c5dbf59890340e592664e43abf9041040 100644 (file)
@@ -74,7 +74,7 @@ get_ppid_of (pid_t pid)
   int fd;
 
   sprintf (filename, "/proc/%u/status", (unsigned int) pid);
-  fd = open (filename, O_RDONLY);
+  fd = open (filename, O_RDONLY | O_CLOEXEC);
   if (fd >= 0)
     {
       char buf[4096 + 1];
@@ -115,7 +115,7 @@ get_ppid_of (pid_t pid)
   int fd;
 
   sprintf (filename, "/proc/%u/status", (unsigned int) pid);
-  fd = open (filename, O_RDONLY);
+  fd = open (filename, O_RDONLY | O_CLOEXEC);
   if (fd >= 0)
     {
       char buf[4096 + 1];
@@ -152,7 +152,7 @@ get_ppid_of (pid_t pid)
   int fd;
 
   sprintf (filename, "/proc/%u/psinfo", (unsigned int) pid);
-  fd = open (filename, O_RDONLY);
+  fd = open (filename, O_RDONLY | O_CLOEXEC);
   if (fd >= 0)
     {
       char buf[4096 + 1];
@@ -190,7 +190,7 @@ get_ppid_of (pid_t pid)
   int fd;
 
   sprintf (filename, "/proc/%u/psinfo", (unsigned int) pid);
-  fd = open (filename, O_RDONLY);
+  fd = open (filename, O_RDONLY | O_CLOEXEC);
   if (fd >= 0)
     {
       /* The contents is a 'struct psinfo'.  But since 'struct psinfo'
@@ -283,7 +283,7 @@ get_ppid_of (pid_t pid)
   int fd;
 
   sprintf (filename, "/proc/pinfo/%u", pid);
-  fd = open (filename, O_RDONLY);
+  fd = open (filename, O_RDONLY | O_CLOEXEC);
   if (0 <= fd)
     {
       prpsinfo_t buf;
index 4f2cad1b2c86414821616ad127373e1456f50748..84e3d793b3a99704cf83fd63e8bb9b0af35e4c68 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 extensions
 sys_types
 unistd
+open
 
 configure.ac: