Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: distinguishing pipes from files Message-ID: <6712@brl-smoke.ARPA> Date: Sat, 21-Nov-87 19:58:07 EST Article-I.D.: brl-smok.6712 Posted: Sat Nov 21 19:58:07 1987 Date-Received: Mon, 23-Nov-87 05:43:19 EST References: <454@rocksanne.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 14 In article <454@rocksanne.UUCP> fuss@rocksanne.UUCP (William Fuss) writes: >Can a process can recognize the "source" of its input/output ??? Yes, the usual way is to perform an fstat() system call on the file descriptor, then use some of the macros defined in on the st_mode field of the data structure returned by fstat() to determine the inode type (regular file, FIFO/pipe, directory, etc.). Another thing that is sometimes done to test whether a file descriptor is associated with a terminal port is to do an ioctl() to get terminal handler parameters. If the ioctl() fails, presumably the inode is not a terminal. This is usually packaged as isatty() in the UNIX C library.