This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: isatty bug


Was that stock Cygwin gdb that crashed?

Try this:

$ cat stest.c
#include <sys/types.h>
#include <sys/stat.h>

int same_tty_p (int fd1, int fd2)
{
  struct stat stat1, stat2;

  return (fstat(fd1, &stat1) >= 0 && fstat(fd2, &stat2) >= 0 &&
          stat1.st_dev == stat2.st_dev && stat2.st_ino == stat2.st_ino);
}

int main(void)
{
  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));
  printf("stat %d bytes\n", sizeof(struct stat));
}

ford@fordpc ~
$ gcc -o stest stest.c

ford@fordpc ~
$ ./stest
0/1: 1
1/2: 1
2/0: 1
stat 96 bytes

$ nm stest.exe | grep fstat
00402970 T __fstat64
004060a4 I __imp___fstat64
004060e0 I __imp__fstat
004027a0 T _fstat

Make sure struct stat is 96 bytes and you are calling fstat64.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]