open.2 (2010 09)
o
open(2) open(2)
types can be kept open for a long time, or indefinitely under some circumstances.
EXAMPLES
The following call to
open() opens file
inputfile for reading only and returns a file descriptor for
inputfile. For an example of reading from file
inputfile, see the read(2) manual entry.
int infd;
infd = open ("inputfile", O_RDONLY);
The following call to open() opens file
outputfile for writing and returns a file descriptor for out-
putfile. For an example of preallocating disk space for
outputfile
, see the prealloc (2) manual
entry. For an example of writing to
outputfile, see the write (2) manual entry.
int outfd;
outfd = open ("outputfile", O_WRONLY);
The following call opens file iofile for synchronized I/O file integrity for reads and writes.
int iofd;
iofd = open ("iofile", O_RDWR|O_SYNC|O_RSYNC);
AUTHOR
open() was developed by HP, AT&T, and the University of California, Berkeley.
SEE ALSO
acl(2), chmod(2), close(2), creat(2), dup(2), fcntl(2), flock(2), lockf(2), lseek(2), creat64(2), pathconf(2),
read(2), select(2), umask(2), write(2), setacl(2), acl(5), aclv(5), fcntl(5), privileges(5), signal(5),
thread_safety(5), unistd(5).
STANDARDS CONFORMANCE
open(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, POSIX.4
4 Hewlett-Packard Company − 4 − HP-UX 11i Version 3: September 2010