How to determine file being redirected to in C

Roger A. Cornelius rac at sherpa.UUCP
Mon Feb 27 17:23:39 AEST 1989


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
least the Xenix version of cat, I don't think the BSD version does),
i.e.:

	cat catfile > catfile

produces the error "cat: input catfile is output".
Any help appreciated.

Roger      rac at sherpa
           uunet!sherpa!rac



More information about the Comp.unix.questions mailing list