Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpfcso!hpfcdc!darko From: darko@hpfcdc.HP.COM (David Arko) Newsgroups: comp.unix.programmer Subject: Re: How to determine the destination of standard output? Message-ID: <32310001@hpfcdc.HP.COM> Date: 8 Feb 91 15:32:37 GMT References: <1991Feb6.204432.2850@cubmol.bio.columbia.edu> Organization: HP Fort Collins, Co. Lines: 13 Any easy way to know if a file descriptor is going to a tty is to use the isatty(3C) library call on it (ie. if(isatty(1)) ...) To check if it is going to a pipe, you may have to use the stat(2),stat(5) (or actually fstat()) system call on file descriptor 1, and look at the st_mode field, in particular, the S_IFIFO bit field to tell if stdout is a pipe. The st_mode field will also tell you if it is going to a character or block device, or if it is a regular file... all you ever wanted to know and more..., see the man page for more detailed -- David (darko@hpfcrn.fc.hp.com)