diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 2b97b08f6..63e1862bd 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2006-08-09 Christopher Faylor + + * 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 * autoload.cc (NtSetInformationFile): Define. diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index d1d234dee..25ef3d62f 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -507,6 +507,7 @@ LoadDLLfuncEx (FindVolumeClose, 4, kernel32, 1) 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) @@ -516,6 +517,7 @@ LoadDLLfuncEx (IsWow64Process, 8, 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) diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc index 004ddec0f..5e92d40a1 100644 --- a/winsup/cygwin/debug.cc +++ b/winsup/cygwin/debug.cc @@ -166,6 +166,7 @@ add_handle (const char *func, int ln, HANDLE h, const char *name, bool inh) 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); } @@ -234,9 +235,10 @@ close_handle (const char *func, int ln, HANDLE h, const char *name, bool force) 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 diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index d1ee321e5..2771d87e0 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -422,6 +422,8 @@ spawn_guts (const char * prog_arg, const char *const *argv, 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; @@ -447,8 +449,6 @@ spawn_guts (const char * prog_arg, const char *const *argv, 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