Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!eos!shelby!Portia!hanauma.stanford.edu!joe From: joe@hanauma (Joe Dellinger) Newsgroups: comp.unix.wizards Subject: What "isatty"? Message-ID: <2421@Portia.Stanford.EDU> Date: 21 May 89 07:47:27 GMT Sender: USENET News System Reply-To: joe@hanauma.stanford.edu (Joe Dellinger) Organization: Stanford University, Dept. of Geophysics Lines: 42 I have a graphics driver program which has 2 basic behaviours. If you do pspen < plot.data > file it writes postscript code to "file". If you do pspen < plot.data it spools the postscript for you. The way it tells whether the output is redirected or not is by doing if ( isatty( fileno( stdout ) ) ) { write into a temp file, then spool it } else { just write to stdout } unfortunately, this doesn't work if the person runs the program in background as part of a script, logs out, and nobody else happens to be using the terminal when the program eventually runs. In this case "isatty" answers "no" for either case. Questions: Where is stdout pointing in such a case? Where does stuff written to it go? How can I tell whether stdout is redirected or not on the command line, given that "isatty" turns out to not do the job? We've had strange problems with the permissions on "/dev/tty" randomly changing to "crw--w--w-", causing many strange errors. I think writing to stdout and stderr when these are no longer attached to a terminal may be causing this. Any similar experiences out there? The programs in question are NOT running with any special privileges, so if they can somehow change permissions on /dev/tty it is a bug in the OS. If the answers to any of the above questions are obvious, please only answer if you roll double sixes on a pair of dice on the first try! \ /\ /\ /\/\/\/\/\/\/\.-.-.-.-.......___________ \ / \ / \ /Dept of Geophysics, Stanford University \/\/\.-.-....___ \/ \/ \/Joe Dellinger joe@hanauma.stanford.edu apple!hanauma!joe\/\.-._