more unix jokes - /dev/null

Doug Gwyn gwyn at smoke.ARPA
Fri Sep 23 03:41:44 AEST 1988


In article <813 at philmds.UUCP>, leo at philmds.UUCP (Leo de Wit) writes:
- In article <8541 at smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
- >In article <811 at philmds.UUCP> leo at philmds.UUCP (Leo de Wit) writes:
- >>>	command > /dev/null
- >>    command >&-
- >But that is not equivalent.  In particular, an error will occur when
- >output is attempted to fd#1.
- 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!):

The program did NOT behave okay.
However, since you did not test your printf/fprintf return status,
you didn't discover that.
More carefully written applications would FAIL when writing to a
closed file descriptor.

The Bourne shell closes the file descriptor for >&- etc.



More information about the Comp.unix.questions mailing list