mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-30 19:10:36 +08:00
* fhandler.cc (fhandler_base::set_inheritance): Just use DUPLICATE_CLOSE_SOURCE
to change inheritance. Eliminate all other logic dealing with closed handles. * fhandler.h (fhandler_base::set_inheritance): Reflect above change. * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Ditto.
This commit is contained in:
parent
b1711a1f96
commit
c50d56bc43
@ -1,3 +1,11 @@
|
|||||||
|
Thu Sep 20 16:48:44 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* fhandler.cc (fhandler_base::set_inheritance): Just use
|
||||||
|
DUPLICATE_CLOSE_SOURCE to change inheritance. Eliminate all other
|
||||||
|
logic dealing with closed handles.
|
||||||
|
* fhandler.h (fhandler_base::set_inheritance): Reflect above change.
|
||||||
|
* fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Ditto.
|
||||||
|
|
||||||
Thu Sep 20 13:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
Thu Sep 20 13:34:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler_socket.cc (fhandler_socket::fixup_after_exec): Close
|
* fhandler_socket.cc (fhandler_socket::fixup_after_exec): Close
|
||||||
|
@ -29,7 +29,7 @@ enum
|
|||||||
class child_info
|
class child_info
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DWORD zero[1]; // must be zeroed
|
DWORD zero[4]; // must be zeroed
|
||||||
DWORD cb; // size of this record
|
DWORD cb; // size of this record
|
||||||
DWORD type; // type of record
|
DWORD type; // type of record
|
||||||
int cygpid; // cygwin pid of child process
|
int cygpid; // cygwin pid of child process
|
||||||
|
@ -1510,44 +1510,18 @@ fhandler_pipe::lseek (off_t offset, int whence)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUGGING
|
|
||||||
#define nameparm name
|
|
||||||
#else
|
|
||||||
#define nameparm
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_base::set_inheritance (HANDLE &h, int not_inheriting, const char *nameparm)
|
fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
|
||||||
#undef nameparm
|
|
||||||
{
|
{
|
||||||
HANDLE newh;
|
/* Note that we could use SetHandleInformation here but it is not available
|
||||||
|
on all platforms. Test cases seem to indicate that using DuplicateHandle
|
||||||
if (wincap.has_set_handle_information () && (!is_console () ||
|
in this fashion does not actually close the original handle, which is
|
||||||
wincap.has_set_handle_information_on_console_handles ()))
|
what we want. If this changes in the future, we may be forced to use
|
||||||
(void) SetHandleInformation (h, HANDLE_FLAG_INHERIT,
|
SetHandleInformation on newer OS's */
|
||||||
not_inheriting ? 0 : HANDLE_FLAG_INHERIT);
|
if (!DuplicateHandle (hMainProc, h, hMainProc, &h, 0, !not_inheriting,
|
||||||
else if (!DuplicateHandle (hMainProc, h, hMainProc, &newh, 0, !not_inheriting,
|
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
||||||
DUPLICATE_SAME_ACCESS))
|
debug_printf ("DuplicateHandle failed, %E");
|
||||||
debug_printf ("DuplicateHandle %E");
|
#ifdef DEBUGGING
|
||||||
#ifndef DEBUGGING
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hclose (h);
|
|
||||||
h = newh;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
else if (!name)
|
|
||||||
{
|
|
||||||
hclose (h);
|
|
||||||
h = newh;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* FIXME: This won't work with sockets */
|
|
||||||
{
|
|
||||||
ForceCloseHandle2 (h, name);
|
|
||||||
h = newh;
|
|
||||||
ProtectHandle2 (h, name);
|
|
||||||
}
|
|
||||||
setclexec_pid (h, not_inheriting);
|
setclexec_pid (h, not_inheriting);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -310,8 +310,7 @@ public:
|
|||||||
unsigned long get_namehash () { return namehash; }
|
unsigned long get_namehash () { return namehash; }
|
||||||
|
|
||||||
virtual void hclose (HANDLE h) {CloseHandle (h);}
|
virtual void hclose (HANDLE h) {CloseHandle (h);}
|
||||||
virtual void set_inheritance (HANDLE &h, int not_inheriting,
|
virtual void set_inheritance (HANDLE &h, int not_inheriting);
|
||||||
const char *name = NULL);
|
|
||||||
|
|
||||||
/* fixup fd possibly non-inherited handles after fork */
|
/* fixup fd possibly non-inherited handles after fork */
|
||||||
void fork_fixup (HANDLE parent, HANDLE &h, const char *name);
|
void fork_fixup (HANDLE parent, HANDLE &h, const char *name);
|
||||||
|
@ -1119,7 +1119,7 @@ fhandler_tty_common::set_close_on_exec (int val)
|
|||||||
/* FIXME: This is a duplication from fhandler_base::set_close_on_exec.
|
/* FIXME: This is a duplication from fhandler_base::set_close_on_exec.
|
||||||
It is here because we need to specify the "from_pty" stuff here or
|
It is here because we need to specify the "from_pty" stuff here or
|
||||||
we'll get warnings from ForceCloseHandle when debugging. */
|
we'll get warnings from ForceCloseHandle when debugging. */
|
||||||
set_inheritance (get_io_handle (), val, "from_pty");
|
set_inheritance (get_io_handle (), val);
|
||||||
set_close_on_exec_flag (val);
|
set_close_on_exec_flag (val);
|
||||||
#endif
|
#endif
|
||||||
if (output_done_event)
|
if (output_done_event)
|
||||||
@ -1130,10 +1130,10 @@ fhandler_tty_common::set_close_on_exec (int val)
|
|||||||
set_inheritance (ioctl_done_event, val);
|
set_inheritance (ioctl_done_event, val);
|
||||||
if (inuse)
|
if (inuse)
|
||||||
set_inheritance (inuse, val);
|
set_inheritance (inuse, val);
|
||||||
set_inheritance (output_mutex, val, "output_mutex");
|
set_inheritance (output_mutex, val);
|
||||||
set_inheritance (input_mutex, val, "input_mutex");
|
set_inheritance (input_mutex, val);
|
||||||
set_inheritance (input_available_event, val);
|
set_inheritance (input_available_event, val);
|
||||||
set_inheritance (output_handle, val, "to_pty");
|
set_inheritance (output_handle, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user