Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb@sourceware.org
Subject: Re: [mingw32] stdin redirection
Date: Thu, 12 Apr 2007 14:56:00 -0000	[thread overview]
Message-ID: <20070412145818.GG3886@adacore.com> (raw)
In-Reply-To: <20070411151234.GA22185@caradoc.them.org>

> So fd_is_pipe returns zero either way, but something about calling
> PeekNamedPipe on a non-pipe disturbs what happens later, you're saying.

Yes, it appears so.

> How did it get into WaitForMultipleObjects?  Did isatty return true -
> in which case it shouldn't have called fd_is_pipe?

One piece of information that might be important is the fact that
we are running from a cygwin shell. In this case, we no longer have
ttys regardless of the way we start GDB (in "terminal" mode, or in
non-interactive mode). However, we tried in a DOS window as well,
and we had the same result: isatty return false, thus leading us
to call fd_is_pipe, followed by the hang up.


> 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?

We've done a bit of debugging on our side, and we now have a better
idea of the serial interface in GDB, and probably of why the select
layer is implemented the way it is implemented in ser-mingw and
mingw-hdep.c. It seems to us that the core of the problem in this
case is that PeekNamedPipe does indeed seem to corrupt whatever
control structure is associated to our HANDLE.

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.

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. We currently have the following
code:

      is_tty = isatty (scb->fd);
      if (!is_tty && !fd_is_pipe (scb->fd))
        {
          *read = NULL;
          *except = NULL;
          return;
        }
      [otherwise, create a bunch of event objects]

All the conditions we have tried (interactive-mode in DOS window,
interactive mode DOS window but called from cygwin shell, interactive
mode from XTERM with cygwin shell, commands sent through pipe in
cygwin shell, commands though pipe in DOS window, commands through
file in both DOS window and XTERM with cygwin, etc...).

So I wonder if it wouldn't just be sufficient to replace the body
of fd_is_pipe by a big comment, followed by "return !isatty (fd);".
Or, since this function only used there, replace the if condition
by
  
      if (!is_tty))

Which basically means that we limit the "else" block to the handling
of the case when we have a tty. We haven't found any problem with
that approach in all the experiments that we have done. Is there
something we haven't seen, though?

Thanks,
-- 
Joel


  reply	other threads:[~2007-04-12 14:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-11 13:42 Jerome Guitton
2007-04-11 14:45 ` Daniel Jacobowitz
2007-04-11 14:51   ` Jerome Guitton
2007-04-11 15:12     ` Daniel Jacobowitz
2007-04-12 14:56       ` Joel Brobecker [this message]
2007-04-12 15:01         ` Dave Korn
2007-04-12 15:04         ` Dave Korn
     [not found]           ` <20070412155422.GI3886@adacore.com>
2007-04-12 15:58             ` Dave Korn
2007-04-12 16:06               ` Joel Brobecker
2007-04-12 16:09                 ` Dave Korn
2007-04-12 15:12         ` Daniel Jacobowitz
2007-04-12 15:51           ` Joel Brobecker
2007-04-12 16:02             ` Daniel Jacobowitz
2007-04-12 16:04             ` Daniel Jacobowitz
2007-04-12 16:29               ` Joel Brobecker
2007-04-12 18:23                 ` Daniel Jacobowitz
2007-04-12 18:56                   ` Daniel Jacobowitz
2007-04-13  9:07                     ` Joel Brobecker
2007-04-12 16:46           ` Joel Brobecker
2007-04-12 17:25             ` Dave Korn
2007-04-13 11:47               ` Jerome Guitton
2007-04-12 19:33             ` Eli Zaretskii
2007-04-12 19:37               ` Mark Kettenis
2007-04-12 19:51               ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070412145818.GG3886@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox