Title: [215346] trunk/Tools
Revision
215346
Author
jbed...@apple.com
Date
2017-04-13 16:20:03 -0700 (Thu, 13 Apr 2017)

Log Message

webkitpy: Ignore previously launched pid when system is under stress
https://bugs.webkit.org/show_bug.cgi?id=170741

Reviewed by David Kilzer.

We have seen cases where xcrun simctl launch will return a pid of a previous
process and the process will appear to be running even though it is crashing.
Ensure that the PID that simulator_process is receiving is not the pid of the
previously run process.

* Scripts/webkitpy/port/simulator_process.py:
(SimulatorProcess._start): Check to make sure we aren't receiving an old PID.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (215345 => 215346)


--- trunk/Tools/ChangeLog	2017-04-13 23:13:41 UTC (rev 215345)
+++ trunk/Tools/ChangeLog	2017-04-13 23:20:03 UTC (rev 215346)
@@ -1,5 +1,20 @@
 2017-04-13  Jonathan Bedard  <jbed...@apple.com>
 
+        webkitpy: Ignore previously launched pid when system is under stress
+        https://bugs.webkit.org/show_bug.cgi?id=170741
+
+        Reviewed by David Kilzer.
+
+        We have seen cases where xcrun simctl launch will return a pid of a previous
+        process and the process will appear to be running even though it is crashing.
+        Ensure that the PID that simulator_process is receiving is not the pid of the
+        previously run process.
+
+        * Scripts/webkitpy/port/simulator_process.py:
+        (SimulatorProcess._start): Check to make sure we aren't receiving an old PID.
+
+2017-04-13  Jonathan Bedard  <jbed...@apple.com>
+
         Build ImageDiff with host SDK
         https://bugs.webkit.org/show_bug.cgi?id=168531
 

Modified: trunk/Tools/Scripts/webkitpy/port/simulator_process.py (215345 => 215346)


--- trunk/Tools/Scripts/webkitpy/port/simulator_process.py	2017-04-13 23:13:41 UTC (rev 215345)
+++ trunk/Tools/Scripts/webkitpy/port/simulator_process.py	2017-04-13 23:20:03 UTC (rev 215346)
@@ -90,11 +90,27 @@
         # Each device has a listening socket intitilaized during the port's setup_test_run.
         # 3 client connections will be accepted for stdin, stdout and stderr in that order.
         self._target_host.listening_socket.listen(3)
-        self._pid = self._target_host.launch_app(self._bundle_id, self._cmd[1:], env=self._env)
 
+        try:
+
+            def launch_failure_handler(signum, frame):
+                assert signum == signal.SIGALRM
+                raise RuntimeError('Faild to launch {}, kept receiving old PID'.format(os.path.basename(self._cmd[0])))
+
+            signal.signal(signal.SIGALRM, launch_failure_handler)
+            signal.alarm(300)  # In seconds
+            pid = self._pid
+            while pid == self._pid:
+                if pid:
+                    self._target_host.executive.kill_process(pid)
+                pid = self._target_host.launch_app(self._bundle_id, self._cmd[1:], env=self._env)
+            self._pid = pid
+        finally:
+            signal.alarm(0)
+
         def handler(signum, frame):
             assert signum == signal.SIGALRM
-            raise Exception('Timed out waiting for pid {} to connect at port {}'.format(self._pid, self._target_host.listening_port()))
+            raise RuntimeError('Timed out waiting for pid {} to connect at port {}'.format(self._pid, self._target_host.listening_port()))
         signal.signal(signal.SIGALRM, handler)
         signal.alarm(6)  # In seconds
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to