OSDN Git Service

* autoload.cc (GetHandleInformation): Declare new function.
authorcgf <cgf>
Wed, 9 Aug 2006 15:04:32 +0000 (15:04 +0000)
committercgf <cgf>
Wed, 9 Aug 2006 15:04:32 +0000 (15:04 +0000)
(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.

winsup/cygwin/ChangeLog
winsup/cygwin/autoload.cc
winsup/cygwin/debug.cc
winsup/cygwin/spawn.cc

index 2b97b08..63e1862 100644 (file)
@@ -1,3 +1,12 @@
+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.
index d1d234d..25ef3d6 100644 (file)
@@ -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)
index 004ddec..5e92d40 100644 (file)
@@ -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
index d1ee321..2771d87 100644 (file)
@@ -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