This is the mail archive of the
mailing list for the GDB project.
Re: [mingw32] stdin redirection
On Thu, Apr 12, 2007 at 04:58:18PM +0200, Joel Brobecker wrote:
> > Otherwise, see the call site, where no handle is provided.
> > So we must be falling back to the file handle (mingw-hdep.c).
> > Maybe we need to do something different to simulate select on a file.
> Sorry, we're not sure what you mean. Could you elaborate?
For a pipe, we use PeekNamedPipe to figure out how many bytes are
available in the pipe and whether select on the pipe should return.
For a file, we use the fallback case: we pass the file's HANDLE to
WaitForMultipleObjects. What does a file HANDLE do when waited on?
Maybe it's not the useful behavior.
> If we could find a way to replace the current implementation of
> fd_is_pipe into something that avoids using any of the pipe functions,
> then that would probably solve our problem. Unfortunately, despite
> our intensive search of MSDN, nothing turned up.
To the best of my knowledge there is no way.
> However, the little hack we have been using in fd_is_pipe (basically
> always return false) seems to indicate that it is OK to treat the
> case of pipes and files the same way.
I don't believe this. When you wait for a pipe's handle, it returns
that the handle is signalling if it is valid to connect to the pipe.
This condition has nothing to do with whether we can read from the
Are you sure that you tested any case in which fd_is_pipe returned
true? I don't remember exactly what the failure mode was, but it's
not immediately obvious; we decide there is data available, try to
read it, and either block in read or fail to read unexpectedly. So
we run around in readline when we should be sleeping. Remote
debugging is most likely to show this problem, especially "target
remote |" if you have any stubs that talk on stdio.