usenetbinary-newsreaderquickboxtraktkodistabletvshowsqnaptautullifanartsickbeardtvseriesplexswizzinembyseedboxtvdbnzbgetsubtitlewebui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
655 B
23 lines
655 B
11 years ago
|
# NOTE: win32 support is currently experimental, and not recommended
|
||
|
# for production use.
|
||
|
|
||
6 years ago
|
import ctypes
|
||
|
import ctypes.wintypes
|
||
11 years ago
|
|
||
|
# See: http://msdn.microsoft.com/en-us/library/ms724935(VS.85).aspx
|
||
6 years ago
|
SetHandleInformation = ctypes.windll.kernel32.SetHandleInformation # type: ignore
|
||
|
SetHandleInformation.argtypes = (
|
||
|
ctypes.wintypes.HANDLE,
|
||
|
ctypes.wintypes.DWORD,
|
||
|
ctypes.wintypes.DWORD,
|
||
|
)
|
||
11 years ago
|
SetHandleInformation.restype = ctypes.wintypes.BOOL
|
||
|
|
||
|
HANDLE_FLAG_INHERIT = 0x00000001
|
||
|
|
||
|
|
||
6 years ago
|
def set_close_exec(fd: int) -> None:
|
||
11 years ago
|
success = SetHandleInformation(fd, HANDLE_FLAG_INHERIT, 0)
|
||
|
if not success:
|
||
6 years ago
|
raise ctypes.WinError() # type: ignore
|