delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/07/25/17:00:41

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
To: cygwin AT cygwin DOT com
X-Injected-Via-Gmane: http://gmane.org/
Path: not-for-mail
From: Sam Steingold <sds AT gnu DOT org>
Newsgroups: gmane.os.cygwin,comp.unix.questions
Subject: how to check stdin == stdout?
Date: 25 Jul 2002 16:38:32 -0400
Organization: disorganization
Lines: 31
Message-ID: <sa0d6tb8rw7.fsf@glip.premonitia.com>
Reply-To: sds AT gnu DOT org
NNTP-Posting-Host: 65.114.186.226
Mime-Version: 1.0
X-Trace: main.gmane.org 1027629492 28582 65.114.186.226 (25 Jul 2002 20:38:12 GMT)
X-Complaints-To: usenet AT main DOT gmane DOT org
NNTP-Posting-Date: Thu, 25 Jul 2002 20:38:12 +0000 (UTC)
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

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/

- Raw text -


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