[Python-checkins] r61704 - python/trunk/Lib/test/test_signal.py

jeffrey.yasskin python-checkins at python.org
Fri Mar 21 19:25:07 CET 2008


Author: jeffrey.yasskin
Date: Fri Mar 21 19:25:06 2008
New Revision: 61704

Modified:
   python/trunk/Lib/test/test_signal.py
Log:
Try to fix test_signal on FreeBSD. I'm assuming that os.kill is failing to
raise a signal, but switching to subprocess makes the code cleaner anyway.


Modified: python/trunk/Lib/test/test_signal.py
==============================================================================
--- python/trunk/Lib/test/test_signal.py	(original)
+++ python/trunk/Lib/test/test_signal.py	Fri Mar 21 19:25:06 2008
@@ -4,6 +4,7 @@
 import pickle
 import select
 import signal
+import subprocess
 import traceback
 import sys, os, time, errno
 
@@ -40,15 +41,13 @@
             print "handlerB invoked", args
         raise HandlerBCalled(*args)
 
-    def wait(self, child_pid):
-        """Wait for child_pid to finish, ignoring EINTR."""
+    def wait(self, child):
+        """Wait for child to finish, ignoring EINTR."""
         while True:
             try:
-                os.waitpid(child_pid, 0)
+                child.wait()
                 return
             except OSError as e:
-                if e.errno == errno.ECHILD:
-                    return
                 if e.errno != errno.EINTR:
                     raise
 
@@ -69,35 +68,24 @@
         if test_support.verbose:
             print "test runner's pid is", pid
 
-        child = os.fork()
-        if child == 0:
-            os.kill(pid, signal.SIGHUP)
-            exit_subprocess()
+        child = subprocess.Popen(['kill', '-HUP', str(pid)])
         self.wait(child)
         self.assertTrue(self.a_called)
         self.assertFalse(self.b_called)
         self.a_called = False
 
         try:
-            child = os.fork()
-            if child == 0:
-                os.kill(pid, signal.SIGUSR1)
-                exit_subprocess()
+            child = subprocess.Popen(['kill', '-USR1', str(pid)])
             # This wait should be interrupted by the signal's exception.
             self.wait(child)
             self.fail('HandlerBCalled exception not thrown')
         except HandlerBCalled:
-            # So we call it again to reap the child's zombie.
-            self.wait(child)
             self.assertTrue(self.b_called)
             self.assertFalse(self.a_called)
             if test_support.verbose:
                 print "HandlerBCalled exception caught"
 
-        child = os.fork()
-        if child == 0:
-            os.kill(pid, signal.SIGUSR2)
-            exit_subprocess()
+        child = subprocess.Popen(['kill', '-USR2', str(pid)])
         self.wait(child)  # Nothing should happen.
 
         try:


More information about the Python-checkins mailing list