open.2 (2010 09)

o
open(2) open(2)
When opening a FIFO with O_RDONLY or
O_WRONLY set:
If
O_NDELAY is set:
A read-only
open() returns without delay.
A write-only
open() returns an error if no process currently has the file
open for reading.
If
O_NDELAY is clear:
A read-only
open() does not return until a process opens the file for
writing.
A write-only
open() does not return until a process opens the file for
reading.
When opening a file associated with a communication line:
If
O_NDELAY is set:
The
open() returns without waiting for carrier.
If
O_NDELAY is clear:
The
open() does not return until carrier is present.
O_NOCTTY If set, and path identifies a terminal device, open() does not cause the terminal to
become the controlling terminal for the process.
O_NOFOLLOW If the last component of path refers to a symbolic link, the open() will fail. This is
true regardless of whether the target of the link exists or not.
NOTE: If the symbolic link in path is followed by a trailing ’/’, the link will be
traversed, regardless of the setting of
O_NOFOLLOW.
O_NONBLOCK Same effect as O_NDELAY for open(2), but slightly different effect in read (2) and
write (2). If both
O_NONBLOCK and O_NDELAY are specified, O_NONBLOCK takes
precedence.
O_TRUNC If the file exists, its length is truncated to 0 and the mode and owner are
unchanged.
Synchronized I/O Flags
Together, the
O_DSYNC, O_RSYNC, and O_SYNC flags constitute support for Synchronized I/O. These
flags are ignored for files other than ordinary files and block special files on those systems that permit I/O
to block special devices (see pathconf (2)). If both the
O_DSYNC and O_SYNC flags are set, the effect is as
if only the O_SYNC flag was set. The O_RSYNC flag is ignored if it is not set along with the
O_DSYNC or
O_SYNC flag.
O_DSYNC
If a file is opened with O_DSYNC or that flag is set with the F_SETFL option of fcntl(),
writes to that file by the process block until the data specified in the write request and all file
attributes required to retrieve the data are written to the disk. File attributes that are not
necessary for data retrieval (access time, modification time, status change time) are not neces-
sarily written to the disk prior to returning to the calling process.
O_SYNC
Identical to O_DSYNC, with the addition that all file attributes changed by the write operation
(including access time, modification time, and status change time) are also written to the disk
prior to returning to the calling process.
O_RSYNC|O_DSYNC (specified together)
Identical to O_DSYNC for file system writes.
For file system reads, the calling process blocks until the data being read and all file attributes
required to retrieve the data are the same as their image on disk. Writes pending on the data
to be read are executed prior to returning to the calling process.
O_RSYNC|O_SYNC (specified together)
Identical to O_SYNC for file system writes.
Identical to
O_RSYNC|O_DSYNC for file system reads, with the addition that all file attributes
changed by the read operation (including access time, modification time, and status change
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010