[xboxdrv] 09/78: Buttonevent exec: Double fork to avoid zombies

Andrey Rahmatullin wrar-guest at moszumanska.debian.org
Sun Feb 21 17:55:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

wrar-guest pushed a commit to branch master
in repository xboxdrv.

commit 5e49f45d1b6cb00b73e24f14303f2496e45d7380
Author: Evan Purkhiser <evanpurkhiser at gmail.com>
Date:   Fri Aug 30 02:13:25 2013 -0400

    Buttonevent exec: Double fork to avoid zombies
---
 src/buttonevent/exec_button_event_handler.cpp | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/buttonevent/exec_button_event_handler.cpp b/src/buttonevent/exec_button_event_handler.cpp
index 141388b..99ebe89 100644
--- a/src/buttonevent/exec_button_event_handler.cpp
+++ b/src/buttonevent/exec_button_event_handler.cpp
@@ -21,6 +21,7 @@
 #include <boost/tokenizer.hpp>
 #include <errno.h>
 #include <string.h>
+#include <sys/wait.h>
 
 #include "log.hpp"
 
@@ -51,9 +52,17 @@ ExecButtonEventHandler::init(UInput& uinput, int slot, bool extra_devices)
 void
 ExecButtonEventHandler::send(UInput& uinput, bool value)
 {
-  if (value)
+  if (!value)
   {
+    return;
+  }
+
+  pid_t tmp_pid = fork();
+  if (tmp_pid == 0)
+  {
+    // Double fork to reap the child and disown the execed process
     pid_t pid = fork();
+
     if (pid == 0)
     {
       char** argv = static_cast<char**>(malloc(sizeof(char*) * (m_args.size() + 1)));
@@ -69,7 +78,11 @@ ExecButtonEventHandler::send(UInput& uinput, bool value)
         _exit(EXIT_FAILURE);
       }
     }
+
+    _exit(EXIT_SUCCESS);
   }
+
+  waitpid(tmp_pid, NULL, 0);
 }
 
 std::string

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/xboxdrv.git



More information about the Pkg-games-commits mailing list