APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

null

2003/10/27

Nothing. Not zero (though zero may be used to represent it), but nothingness. The /dev/null device is a throw-away bit bucket used when you don't want to see the output: often a cron entry would be something like "/usr/bin/someprog > /dev/null 2>&1"

C language strings are null (zero) terminated, and functions may return NULL pointers if they were supposed to return a pointer to something real. Don't confuse this with the very common convention in the shell and elsewhere of returning 0 for success.

The fact that null is often the same as zero is a source of problems. For example, is a reference to "0" a reference to null or a legitimate attempt to access the very first byte of memory? See section 1.3 and 1.4 of http://www.lysator.liu.se/c/c-faq/c-1.html. A Google search for "NULL Pointer" will lead to all sorts of problems, confusion and errors.



Got something to add? Send me email.




Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Tony Lawrence



"The /dev/null device is a throw-away bit bucket used when you don't want to see the output..."

/dev/null can also be used as a source of input when you want to test EOF logic in a program. A read from /dev/null will always return EOF. Beats waiting until you get to the other end of a big file.

--BigDumbDinosaur


Kerio Samepage


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us





We are questioning more than the philosophy behind our dependence upon limited and limiting systems. We question the power structures that have grown up around such systems (Frank Herbert).





This post tagged: