Xref: utzoo comp.unix.questions:11923 comp.unix.xenix:5149 Path: utzoo!attcan!uunet!ispi!jbayer From: jbayer@ispi.UUCP (Jonathan Bayer) Newsgroups: comp.unix.questions,comp.unix.xenix Subject: Re: How to determine file being redirected to in C Keywords: redirection Message-ID: <475@ispi.UUCP> Date: 28 Feb 89 13:30:11 GMT References: <10@sherpa.UUCP> Reply-To: jbayer@ispi.UUCP (Jonathan Bayer) Distribution: na Organization: Intelligent Software Products, Inc. Lines: 19 In article <10@sherpa.UUCP> rac@sherpa.UUCP (Roger A. Cornelius) writes: >I've been searching for the past several days for references to this, >but haven't been able to find it. I know I've read it somewhere, or >maybe saw it here. Anyway, can someone tell me how to determine (in C) >if output is being redirected, or more precisely, how to determine the >file output is being redirected to. The cat command does this (at Use the stat() and fstat() functions, then compare the inode numbers in the structure. If they are the same then the two files are identical. JB -- Jonathan Bayer Beware: The light at the end of the Intelligent Software Products, Inc. tunnel may be an oncoming dragon 19 Virginia Ave. ...uunet!ispi!jbayer Rockville Centre, NY 11570 (516) 766-2867 jbayer@ispi.UUCP