Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: third_party/pexpect/tests/platform_checks/check2.py

Issue 1398903002: Add third_party/pexpect (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@end-to-end-test
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pexpect/tests/platform_checks/check2.py
diff --git a/third_party/pexpect/tests/platform_checks/check2.py b/third_party/pexpect/tests/platform_checks/check2.py
new file mode 100644
index 0000000000000000000000000000000000000000..0a7d5f89ca86b60594450b3f6cb764b8110ed8ff
--- /dev/null
+++ b/third_party/pexpect/tests/platform_checks/check2.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+import signal
+import os
+import time
+
+def signal_handler (signum, frame):
+ print 'Signal handler called with signal:', signum
+ print 'signal.SIGCHLD=', signal.SIGKILL
+
+# Create a child process for us to kill.
+pid = os.fork()
+if pid == 0:
+ time.sleep(10000)
+
+#signal.signal (signal.SIGCHLD, signal.SIG_IGN)
+signal.signal (signal.SIGCHLD, signal_handler)
+
+print 'Sending SIGKILL to child pid:', pid
+os.kill (pid, signal.SIGKILL)
+
+# SIGCHLD should interrupt sleep.
+# Note that this is a race.
+# It is possible that the signal handler will get called
+# before we try to sleep, but this has not happened yet.
+# But in that case we can only tell by order of printed output.
+interrupted = 0
+try:
+ time.sleep(10)
+except:
+ print 'sleep was interrupted by signal.'
+ interrupted = 1
+
+if not interrupted:
+ print 'ERROR. Signal did not interrupt sleep.'
+else:
+ print 'Signal interrupted sleep. This is good.'
+
+# Let's see if the process is alive.
+try:
+ os.kill(pid, 0)
+ print 'Child is alive. This is ambiguous because it may be a Zombie.'
+except OSError as e:
+ print 'Child appears to be dead.'
+

Powered by Google App Engine
This is Rietveld 408576698