diff options
author | Christopher Faylor <me@cgf.cx> | 2011-10-23 23:01:47 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-10-23 23:01:47 +0400 |
commit | 31d2bedc585420092eb53895c5f5646651f13215 (patch) | |
tree | 4e7ab98f866744fb5fd40c22db63a8113226df41 /winsup | |
parent | 1f012519e4954361e3f5c8ad4eab79cde57a510c (diff) |
* fhandler_tty.cc (fhandler_pty_slave::read): Use consistent way for testing
ReadFile return.
* pipe.cc (fhandler_pipe::create_selectable): Open the write side of the pipe
in message-mode to force writing as "chunks". Explain why.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/pipe.cc | 10 |
3 files changed, 16 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 19ee92fd3..33b7c6c38 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2011-10-23 Christopher Faylor <me.cygwin2011@cgf.cx> + * fhandler_tty.cc (fhandler_pty_slave::read): Use consistent way for + testing ReadFile return. + * pipe.cc (fhandler_pipe::create_selectable): Open the write side of + the pipe in message-mode to force writing as "chunks". Explain why. + +2011-10-23 Christopher Faylor <me.cygwin2011@cgf.cx> + * path.cc (path_conv::get_nt_native_path): Avoid dereferencing path when it is NULL. diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index f3a9a5f34..b019db046 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -812,7 +812,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len) if (readlen) { termios_printf ("reading %d bytes (vtime %d)", readlen, vtime); - if (ReadFile (get_handle (), buf, readlen, &n, NULL) == FALSE) + if (!ReadFile (get_handle (), buf, readlen, &n, NULL)) { termios_printf ("read failed, %E"); raise (SIGHUP); diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index aa56cf531..99c79121e 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -238,9 +238,15 @@ fhandler_pipe::create_selectable (LPSECURITY_ATTRIBUTES sa_ptr, HANDLE& r, It's important to only allow a single instance, to ensure that the pipe was not created earlier by some other process, even if the pid has been reused. We avoid FILE_FLAG_FIRST_PIPE_INSTANCE - because that is only available for Win2k SP2 and WinXP. */ + because that is only available for Win2k SP2 and WinXP. + + Note that the write side of the pipe is opened as PIPE_TYPE_MESSAGE. + This *seems* to more closely mimic Linux pipe behavior and is + definitely required for pty handling since fhandler_pty_master + writes to the pipe in chunks, terminated by newline when CANON mode + is specified. */ r = CreateNamedPipe (pipename, PIPE_ACCESS_INBOUND | overlapped, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1, psize, + PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE, 1, psize, psize, NMPWAIT_USE_DEFAULT_WAIT, sa_ptr); if (r != INVALID_HANDLE_VALUE) |