How to determine file being redirected to in C

Jonathan Bayer jbayer at ispi.UUCP
Tue Feb 28 23:30:11 AEST 1989


In article <10 at sherpa.UUCP> rac at 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 at ispi.UUCP



More information about the Comp.unix.xenix mailing list