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

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man3c/fopen.3c
          +++ new/usr/src/man/man3c/fopen.3c
   1    1  '\" te
   2    2  .\" Copyright 1989 AT&T.
   3    3  .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
   4    4  .\" Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
        5 +.\" Portions Copyright (c) 2013, OmniTI Computer Consulting, Inc.  All Rights Reserved.
   5    6  .\" 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
   6    7  .\" http://www.opengroup.org/bookstore/.
   7    8  .\" 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.
   8    9  .\"  This notice shall appear on any product containing this material.
   9   10  .\" 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.
  10   11  .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  11   12  .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  12   13  .TH FOPEN 3C "Apr 18, 2006"
  13   14  .SH NAME
  14   15  fopen \- open a stream
↓ open down ↓ 6 lines elided ↑ open up ↑
  21   22  .fi
  22   23  
  23   24  .SH DESCRIPTION
  24   25  .sp
  25   26  .LP
  26   27  The \fBfopen()\fR function opens the file whose pathname is the string pointed
  27   28  to by \fIfilename\fR, and associates a stream with it.
  28   29  .sp
  29   30  .LP
  30   31  The argument \fImode\fR points to a string beginning with one of the following
  31      -sequences:
       32 +base sequences:
  32   33  .sp
  33   34  .ne 2
  34   35  .na
  35      -\fB\fBr\fR or \fBrb\fR\fR
       36 +\fB\fBr\fR\fR 
  36   37  .ad
  37   38  .RS 20n
  38   39  Open file for reading.
  39   40  .RE
  40   41  
  41   42  .sp
  42   43  .ne 2
  43   44  .na
  44      -\fB\fBw\fR or \fBwb\fR\fR
       45 +\fB\fBw\fR\fR
  45   46  .ad
  46   47  .RS 20n
  47   48  Truncate to  zero  length or create file for writing.
  48   49  .RE
  49   50  
  50   51  .sp
  51   52  .ne 2
  52   53  .na
  53      -\fB\fBa\fR or \fBab\fR\fR
       54 +\fB\fBa\fR\fR
  54   55  .ad
  55   56  .RS 20n
  56   57  Append; open or create file for writing at end-of-file.
  57   58  .RE
  58   59  
  59   60  .sp
  60   61  .ne 2
  61   62  .na
  62      -\fB\fBr+\fR or \fBrb+\fR or \fBr+b\fR\fR
       63 +\fB\fBr+\fR\fR
  63   64  .ad
  64   65  .RS 20n
  65   66  Open file for update (reading and writing).
  66   67  .RE
  67   68  
  68   69  .sp
  69   70  .ne 2
  70   71  .na
  71      -\fB\fBw+\fR or \fBwb+\fR or \fBw+b\fR\fR
       72 +\fB\fBw+\fR\fR
  72   73  .ad
  73   74  .RS 20n
  74   75  Truncate to zero length or create file for update.
  75   76  .RE
  76   77  
  77   78  .sp
  78   79  .ne 2
  79   80  .na
  80      -\fB\fBa+\fR or \fBab+\fR or \fBa+b\fR\fR
       81 +\fB\fBa+\fR\fR
  81   82  .ad
  82   83  .RS 20n
  83   84  Append; open or create file for update, writing at end-of-file.
  84   85  .RE
  85   86  
  86   87  .sp
  87   88  .LP
       89 +In addition to the base sequences for the \fImode\fR argument above, two
       90 +additional flags are supported via the \fBb\fR character and the \fBe\fR
       91 +character.  Order of these additional flags (including the \fB+\fR) does
       92 +not matter.
       93 +.sp
       94 +.LP
  88   95  The character \fBb\fR has no effect, but is allowed for ISO C standard
  89   96  conformance (see \fBstandards\fR(5)). Opening a file with read mode (\fBr\fR as
  90   97  the first character in the \fImode\fR argument) fails if the file does not
  91   98  exist or cannot be read.
  92   99  .sp
  93  100  .LP
      101 +The character \fBe\fR will cause the underlying file descriptor to be
      102 +opened with the O_CLOEXEC flag as described in \fBopen\fR(2).
      103 +.sp
      104 +.LP
  94  105  Opening a file with append mode (\fBa\fR as the first character in the
  95  106  \fImode\fR argument) causes all subsequent writes to the file to be forced to
  96  107  the then current end-of-file, regardless of intervening calls to
  97  108  \fBfseek\fR(3C). If two separate processes open the same file for append, each
  98  109  process may write freely to the file without fear of destroying output being
  99  110  written by the other.  The output from the two processes will be intermixed in
 100  111  the file in the order in which it is written.
 101  112  .sp
 102  113  .LP
 103  114  When a file is opened with update mode (\fB+\fR as the second or third
↓ open down ↓ 281 lines elided ↑ open up ↑
 385  396  
 386  397  .sp
 387  398  .LP
 388  399  The \fBF\fR character in the \fImode\fR argument is Evolving. In all other
 389  400  respects this function is Standard.
 390  401  .SH SEE ALSO
 391  402  .sp
 392  403  .LP
 393  404  \fBenable_extended_FILE_stdio\fR(3C), \fBfclose\fR(3C), \fBfdopen\fR(3C),
 394  405  \fBfflush\fR(3C), \fBfreopen\fR(3C), \fBfsetpos\fR(3C), \fBrewind\fR(3C),
 395      -\fBattributes\fR(5), \fBlf64\fR(5), \fBstandards\fR(5)
      406 +\fBopen\fR(2), \fBattributes\fR(5), \fBlf64\fR(5), \fBstandards\fR(5)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX