Print this page
3687 fopen() O_CLOEXEC support via the "e" flag

*** 1,9 **** --- 1,10 ---- '\" te .\" Copyright 1989 AT&T. .\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved. .\" Portions Copyright (c) 1992, X/Open Company Limited. All Rights Reserved. + .\" Portions Copyright (c) 2013, OmniTI Computer Consulting, Inc. All Rights Reserved. .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. .\" This notice shall appear on any product containing this material. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
*** 26,98 **** The \fBfopen()\fR function opens the file whose pathname is the string pointed to by \fIfilename\fR, and associates a stream with it. .sp .LP The argument \fImode\fR points to a string beginning with one of the following ! sequences: .sp .ne 2 .na ! \fB\fBr\fR or \fBrb\fR\fR .ad .RS 20n Open file for reading. .RE .sp .ne 2 .na ! \fB\fBw\fR or \fBwb\fR\fR .ad .RS 20n Truncate to zero length or create file for writing. .RE .sp .ne 2 .na ! \fB\fBa\fR or \fBab\fR\fR .ad .RS 20n Append; open or create file for writing at end-of-file. .RE .sp .ne 2 .na ! \fB\fBr+\fR or \fBrb+\fR or \fBr+b\fR\fR .ad .RS 20n Open file for update (reading and writing). .RE .sp .ne 2 .na ! \fB\fBw+\fR or \fBwb+\fR or \fBw+b\fR\fR .ad .RS 20n Truncate to zero length or create file for update. .RE .sp .ne 2 .na ! \fB\fBa+\fR or \fBab+\fR or \fBa+b\fR\fR .ad .RS 20n Append; open or create file for update, writing at end-of-file. .RE .sp .LP The character \fBb\fR has no effect, but is allowed for ISO C standard conformance (see \fBstandards\fR(5)). Opening a file with read mode (\fBr\fR as the first character in the \fImode\fR argument) fails if the file does not exist or cannot be read. .sp .LP Opening a file with append mode (\fBa\fR as the first character in the \fImode\fR argument) causes all subsequent writes to the file to be forced to the then current end-of-file, regardless of intervening calls to \fBfseek\fR(3C). If two separate processes open the same file for append, each process may write freely to the file without fear of destroying output being --- 27,109 ---- The \fBfopen()\fR function opens the file whose pathname is the string pointed to by \fIfilename\fR, and associates a stream with it. .sp .LP The argument \fImode\fR points to a string beginning with one of the following ! base sequences: .sp .ne 2 .na ! \fB\fBr\fR\fR .ad .RS 20n Open file for reading. .RE .sp .ne 2 .na ! \fB\fBw\fR\fR .ad .RS 20n Truncate to zero length or create file for writing. .RE .sp .ne 2 .na ! \fB\fBa\fR\fR .ad .RS 20n Append; open or create file for writing at end-of-file. .RE .sp .ne 2 .na ! \fB\fBr+\fR\fR .ad .RS 20n Open file for update (reading and writing). .RE .sp .ne 2 .na ! \fB\fBw+\fR\fR .ad .RS 20n Truncate to zero length or create file for update. .RE .sp .ne 2 .na ! \fB\fBa+\fR\fR .ad .RS 20n Append; open or create file for update, writing at end-of-file. .RE .sp .LP + In addition to the base sequences for the \fImode\fR argument above, two + additional flags are supported via the \fBb\fR character and the \fBe\fR + character. Order of these additional flags (including the \fB+\fR) does + not matter. + .sp + .LP The character \fBb\fR has no effect, but is allowed for ISO C standard conformance (see \fBstandards\fR(5)). Opening a file with read mode (\fBr\fR as the first character in the \fImode\fR argument) fails if the file does not exist or cannot be read. .sp .LP + The character \fBe\fR will cause the underlying file descriptor to be + opened with the O_CLOEXEC flag as described in \fBopen\fR(2). + .sp + .LP Opening a file with append mode (\fBa\fR as the first character in the \fImode\fR argument) causes all subsequent writes to the file to be forced to the then current end-of-file, regardless of intervening calls to \fBfseek\fR(3C). If two separate processes open the same file for append, each process may write freely to the file without fear of destroying output being
*** 390,395 **** .SH SEE ALSO .sp .LP \fBenable_extended_FILE_stdio\fR(3C), \fBfclose\fR(3C), \fBfdopen\fR(3C), \fBfflush\fR(3C), \fBfreopen\fR(3C), \fBfsetpos\fR(3C), \fBrewind\fR(3C), ! \fBattributes\fR(5), \fBlf64\fR(5), \fBstandards\fR(5) --- 401,406 ---- .SH SEE ALSO .sp .LP \fBenable_extended_FILE_stdio\fR(3C), \fBfclose\fR(3C), \fBfdopen\fR(3C), \fBfflush\fR(3C), \fBfreopen\fR(3C), \fBfsetpos\fR(3C), \fBrewind\fR(3C), ! \fBopen\fR(2), \fBattributes\fR(5), \fBlf64\fR(5), \fBstandards\fR(5)