Title: [217658] trunk/Tools
Revision
217658
Author
jbed...@apple.com
Date
2017-06-01 09:35:58 -0700 (Thu, 01 Jun 2017)

Log Message

webkitpy: Do not send 0 or -1 as a pid to kill_process
https://bugs.webkit.org/show_bug.cgi?id=172818

Reviewed by Darin Adler.

Sending a signal to process 0 will result in all processes in the group receiving
the signal. Sending a signal to process -1 will result in all non-system processes
receiving the signal. Both Executive.kill_process and Executive.check_running_pid
should consider these cases

* Scripts/webkitpy/common/system/executive.py:
(Executive.kill_process): Throw exception if pid is undefined, 0 or negative.
(Executive.check_running_pid): An undefined pid, pid 0 or a negative pid will
never be running, although os.kill may succeed.
* Scripts/webkitpy/port/simulator_process.py:
(SimulatorProcess.stop): Do not kill process if it is undefined.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (217657 => 217658)


--- trunk/Tools/ChangeLog	2017-06-01 16:22:05 UTC (rev 217657)
+++ trunk/Tools/ChangeLog	2017-06-01 16:35:58 UTC (rev 217658)
@@ -1,3 +1,22 @@
+2017-06-01  Jonathan Bedard  <jbed...@apple.com>
+
+        webkitpy: Do not send 0 or -1 as a pid to kill_process
+        https://bugs.webkit.org/show_bug.cgi?id=172818
+
+        Reviewed by Darin Adler.
+
+        Sending a signal to process 0 will result in all processes in the group receiving 
+        the signal. Sending a signal to process -1 will result in all non-system processes
+        receiving the signal. Both Executive.kill_process and Executive.check_running_pid
+        should consider these cases
+
+        * Scripts/webkitpy/common/system/executive.py:
+        (Executive.kill_process): Throw exception if pid is undefined, 0 or negative.
+        (Executive.check_running_pid): An undefined pid, pid 0 or a negative pid will
+        never be running, although os.kill may succeed.
+        * Scripts/webkitpy/port/simulator_process.py:
+        (SimulatorProcess.stop): Do not kill process if it is undefined.
+
 2017-05-31  Alexey Proskuryakov  <a...@apple.com>
 
         JSC EWS bot does not run on WTF only patches

Modified: trunk/Tools/Scripts/webkitpy/common/system/executive.py (217657 => 217658)


--- trunk/Tools/Scripts/webkitpy/common/system/executive.py	2017-06-01 16:22:05 UTC (rev 217657)
+++ trunk/Tools/Scripts/webkitpy/common/system/executive.py	2017-06-01 16:35:58 UTC (rev 217658)
@@ -185,6 +185,13 @@
         return [script_path]
 
     def kill_process(self, pid):
+        # Killing a process with a pid of 0 or a negative pid is a valid command, but
+        # will kill all processes in this process' group (if 0) or all non-system processes
+        # (if -1) (kill(2)). Throw an exception if this is the behavior requested, this
+        # class is not designed to provide this functionality.
+        if pid is None or pid <= 0:
+            raise RuntimeError('Cannot kill process with invalid pid of {}'.format(pid))
+
         """Attempts to kill the given pid.
         Will fail silently if pid does not exist or insufficient permisssions."""
         if sys.platform.startswith('win32'):
@@ -267,6 +274,10 @@
         return result
 
     def check_running_pid(self, pid):
+        # An undefined process or a negative process are never running.
+        if pid is None or pid <= 0:
+            return False
+
         """Return True if pid is alive, otherwise return False."""
         if sys.platform.startswith('win'):
             return self._win32_check_running_pid(pid)

Modified: trunk/Tools/Scripts/webkitpy/port/simulator_process.py (217657 => 217658)


--- trunk/Tools/Scripts/webkitpy/port/simulator_process.py	2017-06-01 16:22:05 UTC (rev 217657)
+++ trunk/Tools/Scripts/webkitpy/port/simulator_process.py	2017-06-01 16:35:58 UTC (rev 217658)
@@ -120,6 +120,6 @@
         self._proc = SimulatorProcess.Popen(self._pid, stdin, stdout, stderr, self._target_host)
 
     def stop(self, timeout_secs=3.0):
-        if self._proc:
+        if self._proc and self._proc.pid:
             self._target_host.executive.kill_process(self._proc.pid)
         return super(SimulatorProcess, self).stop(timeout_secs)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to