summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/flags.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2011-06-26 16:42:39 +0000
committerchristos <christos@NetBSD.org>2011-06-26 16:42:39 +0000
commitbbeb5403be5330b145ad01ccdbfa305d3bf8a76d (patch)
treed1be829e69cabc22b138aada13975946ca6ac102 /lib/libc/stdio/flags.c
parent8b2572853f09a752d637652a9e7abb15ea88c254 (diff)
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html). - Add F_DUPFD_CLOEXEC to fcntl(2). - Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing. - Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK. - Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK. - Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter for socket(2) and socketpair(2). - Add new paccept(2) syscall that takes an additional sigset_t to alter the sigmask temporarily and a flags argument to set SOCK_CLOEXEC, SOCK_NONBLOCK. - Add new mode character 'e' to fopen(3) and popen(3) to open pipes and file descriptors for close on exec. - Add new kqueue1(2) syscall with a new flags argument to open the kqueue file descriptor with O_CLOEXEC, O_NONBLOCK. * Fix the system calls that take socklen_t arguments to actually do so. * Don't include userland header files (signal.h) from system header files (rump_syscallargs.h). * Bump libc version for the new syscalls.
Diffstat (limited to 'lib/libc/stdio/flags.c')
-rw-r--r--lib/libc/stdio/flags.c14
1 files changed, 8 insertions, 6 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 */