Whither /dev/null ?

Dave Korn dave.korn@artimi.com
Fri Sep 14 15:15:00 GMT 2007

On 14 September 2007 16:09, Jean-Claude Gervais wrote:

> If I write the following
> ls > nul
> It works as expected under Cygwin, however under Linux I must write
> ls > /dev/null

  'NUL' is a DOS device name, like COM1; cygwin implicitly supports it because
when it passes the open call to the underlying OS, the OS opens NUL as if it
were a real file that existed in every directory.

  /dev/null is the linux equivalent, and it works on cygwin too.

> I searched and found discussions on the Cygwin mailing list that seemed
> to say that Cygwin supported (supports?) the /dev/null device, but I
> checked my installation and this pseudo-device didn't seem to exist on
> my system. The '/dev' folder was missing.
> I discovered that if I created the folder '/dev', afterwards
> the /dev/null device existed, even if it does not appear as an actual
> file under /dev
> I installed cygwin only a few weeks ago using the
> http://www.cygwin.com/setup.exe method, and it was missing the /dev
> folder.
> I compared this to the other machines around me which are running a
> version of Cygwin which is about two years old, same results: /dev is
> missing, but creating it unleashes the /dev/null pseudo-device.

  Yes, /dev is missing, it's a pseudo-directory.  Creating it allows you to
*see* /dev/null in a dir listing, but even without doing so, /dev/null *does*
work, right from the off.

> I'm wondering what is the best way to deal with this? 

  Just use '/dev/null' always and everywhere, it works perfectly on both
cygwin and linux, regardless of whether or not you actually create a real
physical /dev directory.

Can't think of a witty .sigline today....

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list