Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

open(2) OSS System Calls Reference Manual
File Status Flags
The file status flags that specify special open processing are:
O_CREAT Create and open the file. If the file exists, this flag has no effect except as noted
under the O_EXCL flag. If the file does not exist, a regular file is created with
these characteristics:
If access control lists (ACLs) are supported, ACL entries are added to
the file ACL as described in "ACL Inheritance" in the acl(5) reference
page.
The owner ID of the file is set to the effective user ID of the process.
The group ID of the file is determined by the value of the S_ISGID flag
in the parent directory. If S_ISGID is set, the group ID of the file is set to
the group ID of the parent directory; otherwise, the group ID of the file is
set to the effective group ID of the calling process. If the file is a Guar-
dian file (that is, within /G), the group ID is set to that of the primary
group of the effective user ID.
The file permission and attribute bits are set to the value of the mode
parameter, modified as listed:
The file permission bits are set as described in "ACL Inheri-
tance" in the acl(5) reference page.
The set user ID attribute (S_ISUID bit) is cleared.
The set group ID attribute (S_ISGID bit) is cleared.
If bits other than the file permission and appropriate file-type bits are set
in the mode parameter, errno is set to [EINVAL].
O_EXCL Open the file in exclusive access mode.
If the file exists and the O_EXCL and O_CREAT flags are set, the open fails. If
the file exists and the O_EXCL flag is set and the O_CREAT flag is not set, the
open succeeds.
O_NOCTTY Open the file but not as a controlling terminal. If the path parameter identifies a
terminal device, this flag ensures that the terminal device does not become the
controlling terminal for the process.
When opening a file that is not a terminal device, the O_NOCTTY flag is
ignored.
O_TRUNC Open the file and empty it. If the file does not exist or if the file is not a regular
file, this flag has no effect. If the file exists and is a regular file, and if the file is
successfully opened with either read/write access or write-only access:
The length of the file is truncated to 0 (zero).
The owner and group of the file are unchanged.
The set user ID attribute of the file mode is cleared.
56 Hewlett-Packard Company 527186-023