Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Make sure we can deliver two file descriptors for p...
details: https://anonhg.NetBSD.org/src/rev/6b38498f53d7
branches: trunk
changeset: 779295:6b38498f53d7
user: martin <martin%NetBSD.org@localhost>
date: Wed May 16 09:41:11 2012 +0000
description:
Make sure we can deliver two file descriptors for pipe2() before we set
up anything special (like close on exec).
Fixes PR kern/46457.
diffstat:
sys/kern/sys_pipe.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diffs (48 lines):
diff -r 1ec8e15cb3a8 -r 6b38498f53d7 sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c Wed May 16 09:06:35 2012 +0000
+++ b/sys/kern/sys_pipe.c Wed May 16 09:41:11 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.135 2012/01/25 00:28:36 christos Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.136 2012/05/16 09:41:11 martin Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.135 2012/01/25 00:28:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.136 2012/05/16 09:41:11 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -267,21 +267,23 @@
if (error)
goto free2;
retval[0] = fd;
- rf->f_flag = FREAD | flags;
- rf->f_type = DTYPE_PIPE;
- rf->f_data = (void *)rpipe;
- rf->f_ops = &pipeops;
- fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0);
error = fd_allocfile(&wf, &fd);
if (error)
goto free3;
retval[1] = fd;
+
+ rf->f_flag = FREAD | flags;
+ rf->f_type = DTYPE_PIPE;
+ rf->f_data = (void *)rpipe;
+ rf->f_ops = &pipeops;
+ fd_set_exclose(l, (int)retval[0], (flags & O_CLOEXEC) != 0);
+
wf->f_flag = FWRITE | flags;
wf->f_type = DTYPE_PIPE;
wf->f_data = (void *)wpipe;
wf->f_ops = &pipeops;
- fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0);
+ fd_set_exclose(l, (int)retval[1], (flags & O_CLOEXEC) != 0);
rpipe->pipe_peer = wpipe;
wpipe->pipe_peer = rpipe;
Home |
Main Index |
Thread Index |
Old Index