Jelajahi Sumber

Added a SIGSTOP to try and end forking

Essentially, a SIGTERM to the wrong process before
the right process could result in a fork() that causes
a rogue process to not be SIGTERMed. The SIGKILL ends
up cleaning this out anyway, but we really want to
avoid that if possible.

Sending SIGSTOP to all the processes before SIGTERM
tells them to stop allowing fork() calls. Then, when
we call SIGTERM we should not have any rogue processes
as the result of unprotected fork()ing.

Also, dropped some unneeded sleep() calls that just
slowed down each test run.
msmith-techempower 8 tahun lalu
induk
melakukan
061a4371a1
1 mengubah file dengan 10 tambahan dan 8 penghapusan
  1. 10 8
      toolset/benchmark/benchmarker.py

+ 10 - 8
toolset/benchmark/benchmarker.py

@@ -689,19 +689,21 @@ class Benchmarker:
   ############################################################
   def __stop_test(self, out, process):
     if process is not None and process.poll() is None:
+      # Stop the ancestry PIDs so they don't fork anymore.
       pids = self.__find_child_processes(process.pid)
       if pids is not None:
-        kill = ['kill'] + pids
-        subprocess.call(kill, stderr=out, stdout=out)
-      # Normal SIGTERM exits can take some time
-      time.sleep(5)
-      # Okay, if there are any more PIDs, kill them harder
+        stop = ['kill', '-STOP'] + pids
+        subprocess.call(stop, stderr=out, stdout=out)
+      # Kill the ancestry PIDs.
+      pids = self.__find_child_processes(process.pid)
+      if pids is not None:
+        term = ['kill', '-TERM'] + pids
+        subprocess.call(term, stderr=out, stdout=out)
+      # Okay, if there are any more PIDs, kill them harder.
       pids = self.__find_child_processes(process.pid)
       if pids is not None:
-        kill = ['kill', '-9'] + pids
+        kill = ['kill', '-KILL'] + pids
         subprocess.call(kill, stderr=out, stdout=out)
-      # Again, sometimes defunct procs need a moment
-      time.sleep(5)
       process.terminate()
   ############################################################
   # End __stop_test