Browse Source

Maybe it will work via session id

msmith-techempower 8 years ago
parent
commit
fca35a0cdf
2 changed files with 14 additions and 13 deletions
  1. 8 8
      toolset/benchmark/benchmarker.py
  2. 6 5
      toolset/benchmark/framework_test.py

+ 8 - 8
toolset/benchmark/benchmarker.py

@@ -573,9 +573,9 @@ class Benchmarker:
           print "Error: Unable to recover port, cannot start test"
           print "Error: Unable to recover port, cannot start test"
           return exit_with_code(1)
           return exit_with_code(1)
 
 
-        result, pgid = test.start(out)
+        result, sid = test.start(out)
         if result != 0:
         if result != 0:
-          self.__stop_test(pgid, out)
+          self.__stop_test(sid, out)
           time.sleep(5)
           time.sleep(5)
           out.write( "ERROR: Problem starting {name}\n".format(name=test.name) )
           out.write( "ERROR: Problem starting {name}\n".format(name=test.name) )
           out.flush()
           out.flush()
@@ -613,13 +613,13 @@ class Benchmarker:
         ##########################
         ##########################
         out.write(header("Stopping %s" % test.name))
         out.write(header("Stopping %s" % test.name))
         out.flush()
         out.flush()
-        self.__stop_test(pgid, out)
+        self.__stop_test(sid, out)
         out.flush()
         out.flush()
         time.sleep(15)
         time.sleep(15)
 
 
         if self.__is_port_bound(test.port):
         if self.__is_port_bound(test.port):
           # This can happen sometimes - let's try again
           # This can happen sometimes - let's try again
-          self.__stop_test(pgid, out)
+          self.__stop_test(sid, out)
           out.flush()
           out.flush()
           time.sleep(15)
           time.sleep(15)
           if self.__is_port_bound(test.port):
           if self.__is_port_bound(test.port):
@@ -664,7 +664,7 @@ class Benchmarker:
         traceback.print_exc(file=out)
         traceback.print_exc(file=out)
         out.flush()
         out.flush()
         try:
         try:
-          self.__stop_test(pgid, out)
+          self.__stop_test(sid, out)
         except (subprocess.CalledProcessError) as e:
         except (subprocess.CalledProcessError) as e:
           self.__write_intermediate_results(test.name,"<setup.py>#stop() raised an error")
           self.__write_intermediate_results(test.name,"<setup.py>#stop() raised an error")
           out.write(header("Subprocess Error: Test .stop() raised exception %s" % test.name))
           out.write(header("Subprocess Error: Test .stop() raised exception %s" % test.name))
@@ -675,7 +675,7 @@ class Benchmarker:
       # TODO - subprocess should not catch this exception!
       # TODO - subprocess should not catch this exception!
       # Parent process should catch it and cleanup/exit
       # Parent process should catch it and cleanup/exit
       except (KeyboardInterrupt) as e:
       except (KeyboardInterrupt) as e:
-        self.__stop_test(pgid, out)
+        self.__stop_test(sid, out)
         out.write(header("Cleaning up..."))
         out.write(header("Cleaning up..."))
         out.flush()
         out.flush()
         self.__finish()
         self.__finish()
@@ -692,9 +692,9 @@ class Benchmarker:
   # __stop_test(benchmarker)
   # __stop_test(benchmarker)
   # Stops all running tests
   # Stops all running tests
   ############################################################
   ############################################################
-  def __stop_test(self, pgid, out):
+  def __stop_test(self, sid, out):
     try:
     try:
-      subprocess.check_call('sudo kill -9 -%s' % pgid, shell=True, stderr=out, stdout=out)
+      subprocess.check_call('sudo pkill -9 -s %s' % sid, shell=True, stderr=out, stdout=out)
       retcode = 0
       retcode = 0
     except Exception:
     except Exception:
       retcode = 1
       retcode = 1

+ 6 - 5
toolset/benchmark/framework_test.py

@@ -238,11 +238,12 @@ class FrameworkTest:
       out.flush()
       out.flush()
 
 
     # Start the setup.sh command
     # Start the setup.sh command
-    p = subprocess.Popen(command, cwd=self.directory,
-          shell=True, stdout=subprocess.PIPE,
+    p = subprocess.Popen(command,
+          cwd=self.directory,
+          stdout=subprocess.PIPE,
           stderr=subprocess.STDOUT,
           stderr=subprocess.STDOUT,
-          creationFlags=subprocess.CREATE_NEW_PROCESS_GROUP)
-    pgid = os.getpgid(p.pid)
+          start_new_session=True)
+    sid = os.getsid(p.pid)
     nbsr = setup_util.NonBlockingStreamReader(p.stdout,
     nbsr = setup_util.NonBlockingStreamReader(p.stdout,
       "%s: %s.sh and framework processes have terminated" % (self.name, self.setup_file))
       "%s: %s.sh and framework processes have terminated" % (self.name, self.setup_file))
 
 
@@ -339,7 +340,7 @@ class FrameworkTest:
     logging.info("Executed %s.sh, returning %s", self.setup_file, retcode)
     logging.info("Executed %s.sh, returning %s", self.setup_file, retcode)
     os.chdir(previousDir)
     os.chdir(previousDir)
 
 
-    return retcode, pgid
+    return retcode, sid
   ############################################################
   ############################################################
   # End start
   # End start
   ############################################################
   ############################################################