* 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.
This commit is contained in:
Christopher Faylor 2011-10-23 19:01:47 +00:00
parent 1f012519e4
commit 31d2bedc58
3 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,10 @@
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> 2011-10-23 Christopher Faylor <me.cygwin2011@cgf.cx>
* path.cc (path_conv::get_nt_native_path): Avoid dereferencing path * path.cc (path_conv::get_nt_native_path): Avoid dereferencing path

View File

@ -812,7 +812,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
if (readlen) if (readlen)
{ {
termios_printf ("reading %d bytes (vtime %d)", readlen, vtime); 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"); termios_printf ("read failed, %E");
raise (SIGHUP); raise (SIGHUP);

View File

@ -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 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 pipe was not created earlier by some other process, even if
the pid has been reused. We avoid FILE_FLAG_FIRST_PIPE_INSTANCE 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, 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); psize, NMPWAIT_USE_DEFAULT_WAIT, sa_ptr);
if (r != INVALID_HANDLE_VALUE) if (r != INVALID_HANDLE_VALUE)