Makes Cygwin mintty.exe or script.exe show output, if the stack issues got worked around.
Found during investigation in bug: https://bugs.winehq.org/show_bug.cgi?id=47808
Signed-off-by: Bernhard Übelacker bernhardu@mailbox.org --- dlls/ntdll/tests/pipe.c | 8 ++++++++ server/named_pipe.c | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/tests/pipe.c b/dlls/ntdll/tests/pipe.c index 1118f41f81f..6940e0020b7 100644 --- a/dlls/ntdll/tests/pipe.c +++ b/dlls/ntdll/tests/pipe.c @@ -1888,8 +1888,16 @@ static void test_pipe_with_data_state(HANDLE pipe, BOOL is_server, DWORD state) "NtQueryInformationFile(FilePipeLocalInformation) failed in %s state %u: %x\n", is_server ? "server" : "client", state, status); if (!status) + { ok(local_info.NamedPipeState == state, "%s NamedPipeState = %u, expected %u\n", is_server ? "server" : "client", local_info.NamedPipeState, state); + if (state != FILE_PIPE_DISCONNECTED_STATE && state != FILE_PIPE_LISTENING_STATE) + ok(local_info.ReadDataAvailable != 0, "ReadDataAvailable, expected non-zero, in %s state %u\n", + is_server ? "server" : "client", state); + else + ok(local_info.ReadDataAvailable == 0, "ReadDataAvailable, expected zero, in %s state %u\n", + is_server ? "server" : "client", state); + }
status = pNtQueryInformationFile(pipe, &io, &pipe_info, sizeof(pipe_info), FilePipeInformation); if (!is_server && state == FILE_PIPE_DISCONNECTED_STATE) diff --git a/server/named_pipe.c b/server/named_pipe.c index 82f76e98548..37520789722 100644 --- a/server/named_pipe.c +++ b/server/named_pipe.c @@ -844,6 +844,8 @@ static void pipe_end_get_file_info( struct fd *fd, obj_handle_t handle, unsigned case FilePipeLocalInformation: { FILE_PIPE_LOCAL_INFORMATION *pipe_info; + struct pipe_message *message; + data_size_t avail = 0;
if (!(get_handle_access( current->process, handle) & FILE_READ_ATTRIBUTES)) { @@ -880,7 +882,11 @@ static void pipe_end_get_file_info( struct fd *fd, obj_handle_t handle, unsigned pipe_info->MaximumInstances = pipe->maxinstances; pipe_info->CurrentInstances = pipe->instances; pipe_info->InboundQuota = pipe->insize; - pipe_info->ReadDataAvailable = 0; /* FIXME */ + + LIST_FOR_EACH_ENTRY( message, &pipe_end->message_queue, struct pipe_message, entry ) + avail += message->iosb->in_size - message->read_pos; + pipe_info->ReadDataAvailable = avail; + pipe_info->OutboundQuota = pipe->outsize; pipe_info->WriteQuotaAvailable = 0; /* FIXME */ pipe_info->NamedPipeState = pipe_end->state;