* fhandler_tty.cc (fhandler_pty_master::setup): Reorganize so that all
operations for each end of the pipe are grouped together.
This commit is contained in:
parent
d9f2119e32
commit
34cc372abe
@ -1,3 +1,8 @@
|
|||||||
|
2008-07-26 Christopher Faylor <me+cygwin@cgf.cx>
|
||||||
|
|
||||||
|
* fhandler_tty.cc (fhandler_pty_master::setup): Reorganize so that all
|
||||||
|
operations for each end of the pipe are grouped together.
|
||||||
|
|
||||||
2008-07-25 Corinna Vinschen <corinna@vinschen.de>
|
2008-07-25 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* dcrt0.cc (dll_crt0_1): Call malloc_init and user_shared_initialize_1
|
* dcrt0.cc (dll_crt0_1): Call malloc_init and user_shared_initialize_1
|
||||||
|
@ -1362,7 +1362,7 @@ fhandler_pty_master::setup (bool ispty)
|
|||||||
|
|
||||||
char pipename[sizeof("ttyNNNN-from-master")];
|
char pipename[sizeof("ttyNNNN-from-master")];
|
||||||
__small_sprintf (pipename, "tty%d-from-master", get_unit ());
|
__small_sprintf (pipename, "tty%d-from-master", get_unit ());
|
||||||
res = fhandler_pipe::create_selectable (&sec_all, from_master,
|
res = fhandler_pipe::create_selectable (&sec_none_nih, from_master,
|
||||||
get_output_handle (), 128 * 1024,
|
get_output_handle (), 128 * 1024,
|
||||||
pipename);
|
pipename);
|
||||||
if (res)
|
if (res)
|
||||||
@ -1370,13 +1370,9 @@ fhandler_pty_master::setup (bool ispty)
|
|||||||
errstr = "input pipe";
|
errstr = "input pipe";
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
if (!SetHandleInformation (get_output_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
|
||||||
__small_sprintf (pipename, "tty%d-to-master", get_unit ());
|
|
||||||
res = fhandler_pipe::create_selectable (&sec_all, get_io_handle (),
|
|
||||||
to_master, 128 * 1024, pipename);
|
|
||||||
if (res)
|
|
||||||
{
|
{
|
||||||
errstr = "output pipe";
|
errstr = "inheritable get_output_handle ()";
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1384,6 +1380,20 @@ fhandler_pty_master::setup (bool ispty)
|
|||||||
termios_printf ("can't set output_handle(%p) to non-blocking mode",
|
termios_printf ("can't set output_handle(%p) to non-blocking mode",
|
||||||
get_output_handle ());
|
get_output_handle ());
|
||||||
|
|
||||||
|
__small_sprintf (pipename, "tty%d-to-master", get_unit ());
|
||||||
|
res = fhandler_pipe::create_selectable (&sec_none_nih, get_io_handle (),
|
||||||
|
to_master, 128 * 1024, pipename);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
errstr = "output pipe";
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
if (!SetHandleInformation (get_io_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
|
||||||
|
{
|
||||||
|
errstr = "inheritable get_io_handle ()";
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
need_nl = 0;
|
need_nl = 0;
|
||||||
|
|
||||||
/* We do not allow others to open us (for handle duplication)
|
/* We do not allow others to open us (for handle duplication)
|
||||||
@ -1419,20 +1429,6 @@ fhandler_pty_master::setup (bool ispty)
|
|||||||
if (!(input_mutex = CreateMutex (&sec_all, FALSE, buf)))
|
if (!(input_mutex = CreateMutex (&sec_all, FALSE, buf)))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
if (!DuplicateHandle (hMainProc, from_master, hMainProc, &from_master, 0, false,
|
|
||||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
|
||||||
{
|
|
||||||
errstr = "non-inheritable from_master";
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DuplicateHandle (hMainProc, to_master, hMainProc, &to_master, 0, false,
|
|
||||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
|
||||||
{
|
|
||||||
errstr = "non-inheritable to_master";
|
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
t.from_master = from_master;
|
t.from_master = from_master;
|
||||||
t.to_master = to_master;
|
t.to_master = to_master;
|
||||||
// /* screws up tty master */ ProtectHandle1INH (output_mutex, output_mutex);
|
// /* screws up tty master */ ProtectHandle1INH (output_mutex, output_mutex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user