where was mention of what creates NUL files?

Corinna Vinschen corinna-cygwin@cygwin.com
Fri Sep 17 22:46:00 GMT 2010

On Sep 17 11:22, Eric Blake wrote:
> On 09/17/2010 11:12 AM, Daniel Barclay wrote:
> >Does anyone recall a mention of what in CygWin (or possibly Emacs) creates

It's Cygwin, not CygWin.

files with a simple name of "NUL"?
> Windows automagically maps the file named "NUL", in any directory,

Meep!  The Win32 API, not Windows per se.

> to the equivalent of Unix' /dev/null.  Cygwin doesn't create it, but
> all the same, portable programs should never name a file that
> case-insensitively matches 'nul', 'aux', or a host of other
> windows-magic names:
> http://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions
> Meanwhile, cygwin 1.7 has added some magic to use native NT calls to
> work around these limitations, so that you can have a file that
> appears to be named "NUL" from within cygwin, but which is really
> exploiting some 16-bit values outside of Unicode.

Sorry, but that's not entirely correct.  There isn't any magic involved
and the resulting filename is actually "nul".  No mapping to the Unicode
private use area.

The terrible DOS device name hack, which maps filenames containing
substring named like the the old DOS device names (NUL, AUX, PRN, etc)
to the actual Windows device, only exists in the Win32 API.  Cygwin
doesn't use the Win32 API to access files, rather it uses the underlying
native NT API.  This API allows to create and access actual files like
"nul" or "aux.c", just as on any other OS.  The DOS device name hack
simply doesn't affect us.

So, any Cygwin application can create files like "nul".  It happens, for
instance, if you call something like:

  $ echo foo > NUL
  $ ls -l NUL
  -rw-r--r-- 1 corinna vinschen 4 Sep 17 21:25 NUL

Note:  Don't use DOS device names in Cygwin!


    $ echo foo > NUL
    $ echo foo > nul
    $ echo foo > nul:


    $ echo foo > /dev/null

See here:
and here:


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

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

More information about the Cygwin mailing list