Xref: utzoo comp.unix.questions:9374 comp.bugs.4bsd:1018 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!amdahl!oliveb!intelca!mipos3!merlyn From: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Newsgroups: comp.unix.questions,comp.bugs.4bsd Subject: Re: more unix jokes - /dev/null Message-ID: <2928@mipos3.intel.com> Date: 22 Sep 88 20:29:25 GMT References: <8488@smoke.ARPA> <26090@ucbvax.BERKELEY.EDU> <1049@sybase.sybase.com> <1414@star.cs.vu.nl> <811@philmds.UUCP> <8541@smoke.ARPA> <813@philmds.UUCP> Sender: news@mipos3.intel.com Reply-To: merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) Followup-To: comp.unix.questions Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA Lines: 27 In-reply-to: leo@philmds.UUCP (Leo de Wit) In article <813@philmds.UUCP>, leo@philmds (Leo de Wit) writes: | Yes, that would be the result to be expected, wouldn't it? The file | descriptor is closed, and cannot be accessed anymore. However, it seems | like the shell is doing something like redirecting to a /dev/null | device (who can comment on that one?), since the following program | behaved OK (look Ma, no core!): | [program deleted...] I am amazed that people think that any program that doesn't dump core is behaving OK, and vice versa. The shell is *closing* the file descriptors in question. The write calls in your program are getting errors, but you are ignoring them. (Try accessing the value of errno to see the difference.) If you don't try to dump core on purpose because of your bad error return, your program will go merrily on its way. Some better-designed programs, however, *will* notice the difference between a closed file-descriptor and a file descriptor pointing at "/dev/null", and not be happy. Be C-ing you... -- Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 on contract to BiiN Technical Information Services (for now :-), in a former Intel building in Hillsboro, Oregon, USAor ...!tektronix!inteloa[!intelob]!merlyn Standard disclaimer: I *am* my employer!