delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/09/16/14:16:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Injected-Via-Gmane: http://gmane.org/
To: cygwin AT cygwin DOT com
From: Sam Steingold <sds AT gnu DOT org>
Subject: Re: isatty bug
Date: 16 Sep 2003 14:16:05 -0400
Organization: disorganization
Lines: 48
Message-ID: <uekygvbtm.fsf@gnu.org>
References: <usmmxyckr DOT fsf AT gnu DOT org> <20030916100108 DOT GO9981 AT cygbert DOT vinschen DOT de>
<uwuc8x09i DOT fsf AT gnu DOT org> <20030916171951 DOT GA21860 AT redhat DOT com>
<upti0vdxo DOT fsf AT gnu DOT org>
<Pine DOT GSO DOT 4 DOT 56 DOT 0309161332390 DOT 12411 AT slinky DOT cs DOT nyu DOT edu>
Reply-To: sds AT gnu DOT org
Mime-Version: 1.0
X-Complaints-To: usenet AT sea DOT gmane DOT org
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

> * Igor Pechtchanski <crpugpun AT pf DOT alh DOT rqh> [2003-09-16 13:36:30 -0400]:
>
> > > >int main (void) {
> > > >#define Y_N(x)  ((x) ? "(TTY)" : "(not a TTY)")
> > > >  printf("0: %s %s\n1: %s %s\n2: %s %s\n",
> > > >         ttyname(0),Y_N(isatty(0)),ttyname(1),Y_N(isatty(1)),
> > > >         ttyname(2),Y_N(isatty(2)))
>                                         ^
> > > >#undef Y_N
> > > >  return 0;
> > > >}
> > >
> > > Fixing the obvious typo in the above provides the desired results both
> > > inside gdb and outside gdb.  With CYGWIN=tty and with CYGWIN=notty.
> >
> > what is the "obvious typo"?
>
> Aw, come on, try to at least *compile* the code you posted, will ya? ;-)

looks like my cut-and-paste is not as good as it was ... :-)

OK.

what about this:

int same_tty_p (int fd1, int fd2)
{
  struct stat stat1;
  struct stat stat2;
  return ((fstat(fd1,&stat1) >= 0) && (fstat(fd2,&stat2) >= 0) &&
          (stat1.st_dev == stat2.st_dev) && (stat2.st_ino == stat2.st_ino));
}


  printf("0/1: %d\n1/2: %d\n2/0: %d\n",same_tty_p(0,1),
         same_tty_p(1,2),same_tty_p(2,0));


I get crash both in program and gdb (i.e., gdb itself segfaults) on the
fstat() calls.

ps. I am missing "man fstat" - what package do I need for that?

--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
The only time you have too much fuel is when you're on fire.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019