diff options
Diffstat (limited to 'lib/libc/stdio')
| -rw-r--r-- | lib/libc/stdio/flags.c | 14 | ||||
| -rw-r--r-- | lib/libc/stdio/fopen.3 | 26 |
2 files changed, 29 insertions, 11 deletions
diff --git a/lib/libc/stdio/flags.c b/lib/libc/stdio/flags.c index d9772672ed4..191bd23e8b9 100644 --- a/lib/libc/stdio/flags.c +++ b/lib/libc/stdio/flags.c @@ -1,4 +1,4 @@ -/* $NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $ */ +/* $NetBSD: flags.c,v 1.15 2011/06/26 16:42:41 christos Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)flags.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $"); +__RCSID("$NetBSD: flags.c,v 1.15 2011/06/26 16:42:41 christos Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -55,9 +55,7 @@ __RCSID("$NetBSD: flags.c,v 1.14 2003/08/07 16:43:23 agc Exp $"); * Return 0 on error. */ int -__sflags(mode, optr) - const char *mode; - int *optr; +__sflags(const char *mode, int *optr) { int ret, m, o; @@ -90,7 +88,8 @@ __sflags(mode, optr) /* * [rwa]\+ or [rwa]b\+ means read and write - * f means open only plain files. + * f means open only plain files, + * e means set close on exec. */ for (; *mode; mode++) switch (*mode) { @@ -101,6 +100,9 @@ __sflags(mode, optr) case 'f': o |= O_NONBLOCK; break; + case 'e': + o |= O_CLOEXEC; + break; case 'b': break; default: /* We could produce a warning here */ diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3 index ad897b6ab36..b17ae124a12 100644 --- a/lib/libc/stdio/fopen.3 +++ b/lib/libc/stdio/fopen.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: fopen.3,v 1.24 2010/04/05 21:34:47 joerg Exp $ +.\" $NetBSD: fopen.3,v 1.25 2011/06/26 16:42:41 christos Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -33,7 +33,7 @@ .\" .\" @(#)fopen.3 8.1 (Berkeley) 6/4/93 .\" -.Dd June 4, 1993 +.Dd June 24, 2011 .Dt FOPEN 3 .Os .Sh NAME @@ -84,14 +84,20 @@ The file is created if it does not exist. .Pp The .Fa mode -string can also include the letter ``b'' either as a last character or +string can also include the letter +.Dq b +either as a last character or as a character between the characters in any of the two-character strings described above. This is strictly for compatibility with .St -ansiC -and has no effect; the ``b'' is ignored. +and has no effect; the +.Dq b +is ignored. .Pp -The letter ``f'' in the mode string restricts fopen to regular +The letter +.Dq f +in the mode string restricts fopen to regular files; if the file opened is not a regular file, .Fn fopen will fail. @@ -99,6 +105,16 @@ This is a non .St -ansiC extension. .Pp +the letter +.Dq e +in the mode string sets the close-on-exec flag in the file descriptors of +the newly opened file files; if the operation fails, +.Fn fopen +will fail. +This is a non +.St -ansiC +extension. +.Pp Any created files will have mode .Pf \*q Dv S_IRUSR \&| |
