Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site hp-pcd.UUCP Path: utzoo!linus!philabs!cmcl2!floyd!harpo!seismo!hao!hplabs!hp-pcd!hpfcla!hp-dcde!jack From: jack@hp-dcde.UUCP Newsgroups: net.jokes.d Subject: Not a typewriter - (nf) Message-ID: <2509@hp-pcd.UUCP> Date: Tue, 22-Nov-83 03:57:49 EST Article-I.D.: hp-pcd.2509 Posted: Tue Nov 22 03:57:49 1983 Date-Received: Fri, 25-Nov-83 09:27:07 EST Sender: notes_gateway@hp-pcd.UUCP Organization: Hewlett-Packard, Fort Collins, CO Lines: 31 #N:hp-dcde:19600002:000:813 hp-dcde!jack Nov 17 12:21:00 1983 In response to the "Not a typewriter" error message: Apparently, the printf stuff calls isatty(3) to find out if a stream is going to a tty. If so, it buffers the stream. However, isatty sets errno (yoiks!) if the stream isn't a tty. Consider the following sequence: main() { ; if (errno!=0) { printf("*** Horrible thing has occured!\n"); perror("fatal error"); } } The first printf will set errno IF stdout isn't an interactive device, and hence the perror will print the "Not a typewriter" message. However, IF stdout is an interactive device, it will work just fine. Now, I realize that I can save errno right after the error occured, but I shouldn't have to! WHY does isatty (and hence printf) set errno??? -Confused Jack Applin (hplabs!hp-dcd!jack)