* fhandler_tty.cc (fhandler_pty_master::close): Don't close handles if we don't
own them. (fhandler_pty_master::setup): Make sure that original handle is closed when changing inheritance. (fhandler_pty_master::fixup_after_fork): Set from_master/to_master to arch value always. (fhandler_pty_master::fixup_after_exec): Clear from_master/to_master when close_on_exec.
This commit is contained in:
parent
578e142a2b
commit
daff15870e
|
@ -1,3 +1,14 @@
|
||||||
|
2006-06-03 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* fhandler_tty.cc (fhandler_pty_master::close): Don't close handles if
|
||||||
|
we don't own them.
|
||||||
|
(fhandler_pty_master::setup): Make sure that original handle is closed
|
||||||
|
when changing inheritance.
|
||||||
|
(fhandler_pty_master::fixup_after_fork): Set from_master/to_master to
|
||||||
|
arch value always.
|
||||||
|
(fhandler_pty_master::fixup_after_exec): Clear from_master/to_master
|
||||||
|
when close_on_exec.
|
||||||
|
|
||||||
2006-06-03 Christopher Faylor <cgf@timesys.com>
|
2006-06-03 Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
* cygheap.cc (init_cygheap::close_ctty): Remove obsolete code.
|
* cygheap.cc (init_cygheap::close_ctty): Remove obsolete code.
|
||||||
|
|
|
@ -1170,10 +1170,18 @@ fhandler_pty_master::close ()
|
||||||
}
|
}
|
||||||
|
|
||||||
fhandler_tty_master *arch = (fhandler_tty_master *) archetype;
|
fhandler_tty_master *arch = (fhandler_tty_master *) archetype;
|
||||||
if (!ForceCloseHandle (arch->from_master))
|
if (arch->dwProcessId != GetCurrentProcessId ())
|
||||||
termios_printf ("error closing from_master %p, %E", arch->from_master);
|
termios_printf ("not closing from_master(%p)/to_master(%p) since we don't own them(%d)",
|
||||||
if (!ForceCloseHandle (arch->to_master))
|
arch->from_master, arch->to_master, arch->dwProcessId);
|
||||||
termios_printf ("error closing from_master %p, %E", arch->to_master);
|
else
|
||||||
|
{
|
||||||
|
termios_printf ("closing from_master(%p)/to_master(%p) since we own them(%d)",
|
||||||
|
arch->from_master, arch->to_master, arch->dwProcessId);
|
||||||
|
if (!ForceCloseHandle (arch->from_master))
|
||||||
|
termios_printf ("error closing from_master %p, %E", arch->from_master);
|
||||||
|
if (!ForceCloseHandle (arch->to_master))
|
||||||
|
termios_printf ("error closing from_master %p, %E", arch->to_master);
|
||||||
|
}
|
||||||
fhandler_tty_common::close ();
|
fhandler_tty_common::close ();
|
||||||
|
|
||||||
if (!hExeced && get_ttyp ()->master_pid == myself->pid)
|
if (!hExeced && get_ttyp ()->master_pid == myself->pid)
|
||||||
|
@ -1390,14 +1398,14 @@ fhandler_pty_master::setup (tty& t)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!DuplicateHandle (hMainProc, from_master, hMainProc, &from_master, 0, false,
|
if (!DuplicateHandle (hMainProc, from_master, hMainProc, &from_master, 0, false,
|
||||||
DUPLICATE_SAME_ACCESS))
|
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
||||||
{
|
{
|
||||||
errstr = "non-inheritable from_master";
|
errstr = "non-inheritable from_master";
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DuplicateHandle (hMainProc, to_master, hMainProc, &to_master, 0, false,
|
if (!DuplicateHandle (hMainProc, to_master, hMainProc, &to_master, 0, false,
|
||||||
DUPLICATE_SAME_ACCESS))
|
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
||||||
{
|
{
|
||||||
errstr = "non-inheritable to_master";
|
errstr = "non-inheritable to_master";
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -1452,6 +1460,8 @@ fhandler_pty_master::fixup_after_fork (HANDLE parent)
|
||||||
}
|
}
|
||||||
arch->dwProcessId = wpid;
|
arch->dwProcessId = wpid;
|
||||||
}
|
}
|
||||||
|
from_master = arch->from_master;
|
||||||
|
to_master = arch->to_master;
|
||||||
report_tty_counts (this, "inherited master", "");
|
report_tty_counts (this, "inherited master", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1460,4 +1470,6 @@ fhandler_pty_master::fixup_after_exec ()
|
||||||
{
|
{
|
||||||
if (!close_on_exec ())
|
if (!close_on_exec ())
|
||||||
fixup_after_fork (spawn_info->parent);
|
fixup_after_fork (spawn_info->parent);
|
||||||
|
else
|
||||||
|
from_master = to_master = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue