+2006-08-09 Christopher Faylor <cgf@timesys.com>
+
+ * autoload.cc (GetHandleInformation): Declare new function.
+ (SetHandleInformation): Ditto.
+ * debug.cc (add_handle): Use SetHandleInformation to protect handle.
+ (close_handle): Use SetHandleInformation to unprotect handle.
+
+ * spawn.cc (spawn_guts): Move detached test outside of P_OVERLAY block.
+
2006-08-07 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (NtSetInformationFile): Define.
LoadDLLfuncEx2 (GetCompressedFileSizeA, 8, kernel32, 1, 0xffffffff)
LoadDLLfuncEx (GetConsoleWindow, 0, kernel32, 1)
LoadDLLfuncEx (GetDiskFreeSpaceEx, 16, kernel32, 1)
+LoadDLLfuncEx (GetHandleInformation, 8, kernel32, 1)
LoadDLLfuncEx (GetNativeSystemInfo, 4, kernel32, 1)
LoadDLLfuncEx (GetProcessWorkingSetSize, 12, kernel32, 1)
LoadDLLfuncEx (GetVolumeNameForVolumeMountPointA, 12, kernel32, 1)
LoadDLLfuncEx (Process32First, 8, kernel32, 1)
LoadDLLfuncEx (Process32Next, 8, kernel32, 1)
LoadDLLfuncEx (RegisterServiceProcess, 8, kernel32, 1)
+LoadDLLfuncEx (SetHandleInformation, 12, kernel32, 1)
LoadDLLfuncEx (SetProcessWorkingSetSize, 12, kernel32, 1)
LoadDLLfuncEx (SignalObjectAndWait, 16, kernel32, 1)
LoadDLLfuncEx (SwitchToThread, 0, kernel32, 1)
hl->pid = GetCurrentProcessId ();
cygheap->debug.endh->next = hl;
cygheap->debug.endh = hl;
+ SetHandleInformation (h, HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAG_PROTECT_FROM_CLOSE);
debug_printf ("protecting handle '%s'(%p), inherited flag %d", hl->name, hl->h, hl->inherited);
}
if (!mark_closed (func, ln, h, name, force))
return false;
+ SetHandleInformation (h, HANDLE_FLAG_PROTECT_FROM_CLOSE, 0);
ret = CloseHandle (h);
-#if 0 /* Uncomment to see CloseHandle failures */
+#if 1 /* Uncomment to see CloseHandle failures */
if (!ret)
small_printf ("CloseHandle(%s) failed %s:%d\n", name, func, ln);
#endif
if (mode == _P_DETACH)
c_flags |= DETACHED_PROCESS;
+ else
+ set_console_state_for_spawn (real_path.iscygexec ());
if (mode != _P_OVERLAY)
myself->exec_sendsig = NULL;
ProtectHandleINH (cygheap->pid_handle);
else
system_printf ("duplicate to pid_handle failed, %E");
- if (mode != _P_DETACH)
- set_console_state_for_spawn (real_path.iscygexec ());
}
/* Some file types (currently only sockets) need extra effort in the parent