Browse Source

Use setpgrp() so that we don't get SIGINT (Ctrl-C) on the child
processes in BIND 10.

This is Trac ticket #378:

https://bind10.isc.org/ticket/378

Small enough change that no ChangeLog entry added.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@3396 e5f2f494-b856-4b98-b285-d166d9295462

Shane Kerr 14 years ago
parent
commit
99f0a885e2
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/bin/bind10/bind10.py.in

+ 7 - 2
src/bin/bind10/bind10.py.in

@@ -141,9 +141,14 @@ class ProcessInfo:
         self.username = username
         self._spawn()
 
-    def _setuid(self):
+    def _preexec_work(self):
         """Function used before running a program that needs to run as a
         different user."""
+        # First, put us into a separate process group so we don't get
+        # SIGINT signals on Ctrl-C (the boss will shut everthing down by
+        # other means).
+        os.setpgrp()
+        # Second, set the user ID if one has been specified
         if self.uid is not None:
             try:
                 posix.setuid(self.uid)
@@ -177,7 +182,7 @@ class ProcessInfo:
                                         stderr=spawn_stderr,
                                         close_fds=True,
                                         env=spawn_env,
-                                        preexec_fn=self._setuid)
+                                        preexec_fn=self._preexec_work)
         self.pid = self.process.pid
         self.restart_schedule.set_run_start_time()