Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Thu, 25 Jul 2002 17:04:32 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: how to check stdin == stdout? Message-ID: <20020725210432.GF6611@redhat.com> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.3.23.1i On Thu, Jul 25, 2002 at 04:38:32PM -0400, Sam Steingold wrote: >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? On Cygwin stdin is usually CONIN$ and stdout is usually CONOUT$ . So, since inodes are based on filenames, they would be different in this case. Sorry. cgf -- Please do not send me personal email with cygwin questions. Use the resources at http://cygwin.com/ . -- 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/