/dev/null (a BRIEF summary)

Daniel R. Levy levy at ttrdc.UUCP
Sun Nov 24 08:51:06 AEST 1985


Thanks everyone for all the messages I got on this subject.  As of
this writing, I have gotten replies from:

..!castor!rer -Rick Richardson PC Research, Inc.
...!ihnp4!cuuxb!dlm =Dennis L. Mumaugh Lisle, IL  
allegra!fisher!djl ***dan :The misplaced (That car sure is rusty!) Californian
..!ihnp4!mgnetp!mgwess!plw Pete Wilson AT&T IS CGBS Montgomery Works
ulysses!utah-cs!utah-gr!thomas at utah-gr.UTAH-CS (Spencer W. Thomas)
watmath!onfcanim!dave Dave Martindale
nbires!rcd (Dick Dunn)
watmath!watcgl!sahayman Steve Hayman guru in training university of waterloo
ncsu!ncrcae!sauron!wescott Mike Wescott
ihnp4!seismo!BRL.ARPA!ron Ron Natalie
ihnp4!well!perry (Perry S. Kivolowitz)
seismo!mcvax!vu44!ark!gijs Gijs

(I apologize if I have omitted anyone.)

I should have been smart enough to look at the source code before asking this
one.  Several people pointed out where to look.  Since the source is not
public domain, I obviously can't quote it for purposes of summary (on
Sys5R2 on a 3B20 it is in /usr/src/uts/3b/io/mem.c but your mileage may vary).
However, the gist of what happens is that attempts to read() from /dev/null
return 0 (EOF), and write() to /dev/null returns a value equal to the number
of characters you asked to write, both no questions asked.  In fact, you can
throw any pointer, valid or not, at such a request as a buffer location
and no error is produced.  (This happens even if this was from stdout or
stdin, say, and it was redirected to/from /dev/null from the shell.  There-
fore, a corollary is that it would NOT be good debugging practice to attach
ANY file descriptor to /dev/null if one is at the least worried about the
possibility of giving write() or read() there an out-of-bounds or bad pointer.
This aside from the fact that for write() you would want to save the output
anyhow for scrutiny.  Apparently read() from an empty file displays
this same characteristic--the validity of the passed pointer is ignored.
I tried it.)

Thanks again for all the mail.

 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!ihnp4!ttrdc!levy
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!ihnp4!ttrdc!levy



More information about the Comp.unix.wizards mailing list