Xref: utzoo comp.unix.questions:12466 comp.unix.xenix:5454 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!elroy!aero!venera.isi.edu!uci-ics!orion.cf.uci.edu!ucsd!rutgers!tut.cis.ohio-state.edu!unmvax!gatech!kong!emory!arnold From: arnold@mathcs.emory.edu (Arnold D. Robbins {EUCC}) Newsgroups: comp.unix.questions,comp.unix.xenix Subject: Re: How to determine file being redirected to in C Keywords: redirection Message-ID: <3763@emory.mathcs.emory.edu> Date: 1 Mar 89 17:49:03 GMT References: <10@sherpa.UUCP> <475@ispi.UUCP> Reply-To: arnold@emory.UUCP (Arnold D. Robbins {EUCC}) Followup-To: comp.unix.questions Distribution: na Organization: Emory University Lines: 17 >In article <10@sherpa.UUCP> rac@sherpa.UUCP (Roger A. Cornelius) writes: >> 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 In article <475@ispi.UUCP> jbayer@ispi.UUCP (Jonathan Bayer) writes: >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. Rather, compare the device and inode numbers, and if both are the same the two files are really the same file. Two files on two different filesystems (i.e. devices) can both have the same inode numbers. -- "Unix is a Registered | Arnold Robbins -- Emory University Computing Center Bell of AT&T Trademark | DOMAIN: arnold@unix.cc.emory.edu Laboratories." | UUCP: gatech!emory!arnold PHONE: +1 404 727-7636 -- Donn Seeley | BITNET: arnold@emoryu1 FAX: +1 404 727-2599