more unix jokes - /dev/null

Randal L. Schwartz @ Stonehenge merlyn at intelob.intel.com
Fri Sep 23 06:29:25 AEST 1988


In article <813 at philmds.UUCP>, leo at 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, USA
<merlyn at intelob.intel.com> or ...!tektronix!inteloa[!intelob]!merlyn
Standard disclaimer: I *am* my employer!



More information about the Comp.bugs.4bsd.ucb-fixes mailing list