Amaury Forgeot d'Arc  committed af5fc29

After win32-kill branch merge:
- don't import rwin32 on posix platforms
- simplify TerminateProcess error handling

  • Participants
  • Parent commits c0342ec

Comments (0)

Files changed (3)

File pypy/module/posix/

 from pypy.interpreter.error import operationerrfmt
 from pypy.rpython.module.ll_os import RegisterOs
 from pypy.rpython.module import ll_os_stat
-from pypy.rlib import rwin32
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.rpython.tool import rffi_platform
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 def kill(space, pid, sig):
     "Kill a process with a signal."
-        rwin32.os_kill(pid, sig)
+        rposix.os_kill(pid, sig)
     except OSError, e:
         raise wrap_oserror(space, e)
     """Abort the interpreter immediately.  This 'dumps core' or otherwise fails
 in the hardest way possible on the hosting operating system."""
     import signal
-    rwin32.os_kill(os.getpid(), signal.SIGABRT)
+    rposix.os_kill(os.getpid(), signal.SIGABRT)
 @unwrap_spec(src='str0', dst='str0')
 def link(space, src, dst):

File pypy/rlib/

             return nt._getfullpathname(path)
             return nt._getfullpathname(path.as_bytes())
+if == 'nt':
+    from rlib import rwin32
+    os_kill = rwin32.os_kill
+    os_kill = os.kill

File pypy/rlib/

 from pypy.translator.platform import CompilationError
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.rlib.rarithmetic import intmask
-from pypy.rlib.rposix import validate_fd
 from pypy.rlib import jit
 import os, sys, errno
     _get_osfhandle = rffi.llexternal('_get_osfhandle', [rffi.INT], HANDLE)
     def get_osfhandle(fd):
+        from pypy.rlib.rposix import validate_fd
         handle = _get_osfhandle(fd)
         if handle == INVALID_HANDLE_VALUE:
         handle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
         if handle == NULL_HANDLE:
             raise lastWindowsError('os_kill failed opening process')
-        t = TerminateProcess(handle, sig)
-        if t == 0:
-            err = lastWindowsError('os_kill failed to terminate process')
+        try:
+            if TerminateProcess(handle, sig) == 0:
+                raise lastWindowsError('os_kill failed to terminate process')
+        finally:
-            raise err
-        t = CloseHandle(handle)
-        if t == 0:
-            raise lastWindowsError('os_kill after terminating process,'
-                     ' while closing handle') 
-    #not win32
-    os_kill = os.kill