Subject: how to check stdin == stdout?
From: Sam Steingold <[email-masked]>
To: [email-masked]
Date: 25 Jul 2002 16:38:32 -0400
Newsgroups: gmane.os.cygwin,comp.unix.questions

To check that stdin and stdout are the same TTYs,
I use the following code on UNIX (all flavors)

#define stdin_handle   0
#define stdout_handle  1

      struct stat stdin_stat;
      struct stat stdout_stat;
      if ((fstat(stdin_handle,&stdin_stat) >= 0) &&
          (fstat(stdout_handle,&stdout_stat) >= 0))
        if ((stdin_stat.st_dev == stdout_stat.st_dev) &&
            (stdin_stat.st_ino == stdout_stat.st_ino))
          same_tty = true;

it works just fine on all UNIX flavors except for cygwin which has
different inodes:

        stdin_stat.st_ino =3989447614
        stdout_stat.st_ino=3413797845

what's wrong with cygwin?
or maybe my method is incorrect?
so how do I check that 0 and 1 are the same tty?

thanks!

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.3 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Despite the raising cost of living, it remains quite popular.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/