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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 import signal
3 import os
4 import time
5
6 def signal_handler (signum, frame):
7 print 'Signal handler called with signal:', signum
8 print 'signal.SIGCHLD=', signal.SIGKILL
9
10 # Create a child process for us to kill.
11 pid = os.fork()
12 if pid == 0:
13 time.sleep(10000)
14
15 #signal.signal (signal.SIGCHLD, signal.SIG_IGN)
16 signal.signal (signal.SIGCHLD, signal_handler)
17
18 print 'Sending SIGKILL to child pid:', pid
19 os.kill (pid, signal.SIGKILL)
20
21 # SIGCHLD should interrupt sleep.
22 # Note that this is a race.
23 # It is possible that the signal handler will get called
24 # before we try to sleep, but this has not happened yet.
25 # But in that case we can only tell by order of printed output.
26 interrupted = 0
27 try:
28 time.sleep(10)
29 except:
30 print 'sleep was interrupted by signal.'
31 interrupted = 1
32
33 if not interrupted:
34 print 'ERROR. Signal did not interrupt sleep.'
35 else:
36 print 'Signal interrupted sleep. This is good.'
37
38 # Let's see if the process is alive.
39 try:
40 os.kill(pid, 0)
41 print 'Child is alive. This is ambiguous because it may be a Zombie.'
42 except OSError as e:
43 print 'Child appears to be dead.'
44
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698