Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc14
1 files changed, 7 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index d4b710d8f..654b92717 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1339,7 +1339,7 @@ fhandler_tty_master::init_console ()
#define close_maybe(h) \
do { \
- if (h) \
+ if (h && h != INVALID_HANDLE_VALUE) \
CloseHandle (h); \
} while (0)
@@ -1356,10 +1356,6 @@ fhandler_pty_master::setup (bool ispty)
/* Create communication pipes */
- /* FIXME: should this be sec_none_nih? */
-
- /* Create communication pipes */
-
char pipename[sizeof("ttyNNNN-from-master")];
__small_sprintf (pipename, "tty%d-from-master", get_unit ());
res = fhandler_pipe::create_selectable (&sec_none_nih, from_master,
@@ -1370,7 +1366,9 @@ fhandler_pty_master::setup (bool ispty)
errstr = "input pipe";
goto err;
}
- if (!SetHandleInformation (get_output_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
+ /* Only ptys should create inheritable handles by default. ttys are
+ parcelled out on an as-needed basis and handle inheritance differently. */
+ if (ispty && !SetHandleInformation (get_output_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
{
errstr = "inheritable get_output_handle ()";
goto err;
@@ -1388,7 +1386,9 @@ fhandler_pty_master::setup (bool ispty)
errstr = "output pipe";
goto err;
}
- if (!SetHandleInformation (get_io_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
+ /* Only ptys should create inheritable handles by default. ttys are
+ parcelled out on an as-needed basis and handle inheritance differently. */
+ if (ispty && !SetHandleInformation (get_io_handle (), HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT))
{
errstr = "inheritable get_io_handle ()";
goto err;