]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Don't let openvpn_popen() keep zombies around
authorDavid Sommerseth <davids@redhat.com>
Fri, 5 Sep 2014 12:26:32 +0000 (14:26 +0200)
committerDavid Sommerseth <davids@redhat.com>
Thu, 16 Oct 2014 15:07:54 +0000 (17:07 +0200)
Commit 9449e6a9eba30c9ed054f57d630a88c9f087080f introduced the
openvpn_popen() function to support retrieving passwords via systemd.

It was discovered that the child processes openvpn fork()ed would
be lingering around until openvpn stopped.  This was due to the lack
of a wait() call.

This patch also cleans up a few minor white-space issues in the same
code segment.

 [v2 proper initialisation of status variable]

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: 1409930731-15263-2-git-send-email-davids@redhat.com
URL: http://article.gmane.org/gmane.network.openvpn.devel/9021
(cherry picked from commit d886d468849051af525bb8ff1b9080f6c934e3ab)

src/openvpn/misc.c

index a2bd2ccb0b6dbabf25b158376e41c8b3d5756d4d..8408438be13cc68c0310dea22684bed660da6eb1 100644 (file)
@@ -376,8 +376,11 @@ openvpn_popen (const struct argv *a,  const struct env_set *es)
                        }
                      else /* parent side */
                        {
-                            ret=pipe_stdout[0];
-                           close (pipe_stdout[1]);
+                          int status = 0;
+
+                          waitpid(pid, &status, 0);
+                          ret = pipe_stdout[0];
+                          close (pipe_stdout[1]);
                        }
              }
              else {