Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 from __future__ import absolute_import, division, with_statement
00006 import ctypes
00007 import ctypes.wintypes
00008 
00009 
00010 SetHandleInformation = ctypes.windll.kernel32.SetHandleInformation
00011 SetHandleInformation.argtypes = (ctypes.wintypes.HANDLE, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD)
00012 SetHandleInformation.restype = ctypes.wintypes.BOOL
00013 
00014 HANDLE_FLAG_INHERIT = 0x00000001
00015 
00016 
00017 def set_close_exec(fd):
00018     success = SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 0)
00019     if not success:
00020         raise ctypes.GetLastError()