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 To: cygwin AT cygwin DOT com Subject: stderr ?= stdout Mail-Copies-To: never Reply-To: sds AT gnu DOT org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. From: Sam Steingold Mail-Followup-To: cygwin AT cygwin DOT com Date: Wed, 12 Jan 2005 15:14:54 -0500 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain How do I check whether stdout==stderr or not? e.g., I want to distinguish between these situations: $ foo $ foo > log $ foo 1>log1 2>log2 struct stat statbuf1; struct stat statbuf2; fstat(handle1,&statbuf1) fstat(handle2,&statbuf2) if (statbuf1.st_dev == statbuf2.st_dev && statbuf1.st_ino == statbuf2.st_ino) { /* handle1 and handle2 point to the same inode. */ if ((S_ISREG(statbuf1.st_mode) || S_ISBLK(statbuf1.st_mode)) && (S_ISREG(statbuf2.st_mode) || S_ISBLK(statbuf2.st_mode))) { /* handle1 and handle2 are exchangeable only if they are positioned at the same file position. */ off_t pos1 = lseek(handle1,0,SEEK_CUR); if (pos1 >= 0) { off_t pos2 = lseek(handle2,0,SEEK_CUR); if (pos2 >= 0) return (pos1 == pos2); } } return true; } else return false; alas, the current cygwin reports different inodes for stdout and stderr: -437397064 and 593767114 so, what is the right way to check that two FDs refer to the same device? Thanks! -- Sam Steingold (http://www.podval.org/~sds) running w2k Beliefs divide, doubts unite. -- 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/