zero.7 (2010 09)

z
zero(7) zero(7)
NAME
zero - /dev/zero special file
DESCRIPTION
/dev/zero is a zero special file. Reads from a zero special file always return characters whose value is
0 (\0 characters).
Data written on a zero special file is discarded or ignored.
Seeks on a zero special file always succeed.
When
/dev/zero is memory mapped by calling
mmap(), the associated memory object behaves as a
MAP_ANONYMOUS
object. It is initialized to all zeros. Writes to the object modify the contents of the object
which are observed by subsequent reads to this object.
Both
MAP_SHARED and MAP_PRIVATE mmap() are allowed.
When it is mapped shared, the memory object can be shared only with the descendants of the current pro-
cess. Modifications made to the
MAP_SHARED object are visible only to the process and its descendants.
When it is mapped private, any modifications done after
fork() are visible only to the process.
EXAMPLES
In the following example, the buffer
buf is filled with len \0 characters.
fildes = open("/dev/zero",...)
read(fildes, buf, len)
In the following example, the process now has a range of len \0 characters at memory location
address:
fildes = open("/dev/zero",...)
address = mmap(0, len, PROT_READ | PROT_WRITE,
MAP_PRIVATE, fildes, any_offset)
FILES
/dev/zero
SEE ALSO
mmap(2), null(7).
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)