Talk:/dev/zero

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Linux (Rated Start-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Linux, a collaborative effort to improve the coverage of Linux on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
 
WikiProject Computing / Software (Rated Start-class, Mid-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Mid  This article has been rated as Mid-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Software.
 

I've always wondered why there isn't a /dev/one, or some such, that when read produces a continuous stream of byte 0xFF.

You could create one. Just stick a NOT on the end of /dev/zero... right? --Ihope127 00:13, 12 July 2005 (UTC)

  #! /bin/sh
  tr '\000' '\377' < /dev/zero

Paul Beardsell 03:30, 2 Sep 2004 (UTC)


Some Python code to demonstrate what /dev/zero gives you:

f=open('/dev/zero', 'r')
print repr(f.read(4))
'\x00\x00\x00\x00'

The unix infinite loop[edit]

cp /dev/zero /dev/null

Only if you have a very braindead version of cp. It should copy the device file. Arbitrary username 20:05, 13 June 2006 (UTC)

Then try:

cat /dev/zero > /dev/null

/dev/zero 16:04, 13 September 2006 (UTC)

BSD-way od implementing shared memory[edit]

Mmap can be used to implement shared memory, it is true. But this shared memory need to have storage in file. Using mmap on /dev/zero is equivalent to use MAP_ANON flag. This mapping is anonymous, so can be shared only with children by inheritance. So maping of /dev/zero cannot be used to implement general shared memory.. -- Wieczyk —Preceding unsigned comment added by 81.190.193.233 (talk) 17:03, 15 September 2009 (UTC)