NetBSD Problem Report #45545
From www@NetBSD.org Mon Oct 31 14:33:23 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id 5C3B763D6BF
for <gnats-bugs@gnats.NetBSD.org>; Mon, 31 Oct 2011 14:33:23 +0000 (UTC)
Message-Id: <20111031143322.C46D763B9F9@www.NetBSD.org>
Date: Mon, 31 Oct 2011 14:33:22 +0000 (UTC)
From: naruse@airemix.jp
Reply-To: naruse@airemix.jp
To: gnats-bugs@NetBSD.org
Subject: pipe2's return value is wrong
X-Send-Pr-Version: www-1.0
>Number: 45545
>Category: kern
>Synopsis: pipe2's return value is wrong
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 31 14:35:00 +0000 2011
>Closed-Date: Mon Oct 31 22:33:18 +0000 2011
>Last-Modified: Mon Oct 31 22:33:18 +0000 2011
>Originator: Yui NARUSE
>Release: 5.99.56 i386
>Organization:
>Environment:
NetBSD nbsd.rubyci.org 5.99.56 NetBSD 5.99.56 (GENERIC) #0: Thu Sep 29 12:55:50 JST 2011 naruse@nbsd.rubyci.org:/usr/obj/sys/arch/i386/compile/GENERIC i386
>Description:
pipe2(2)'s returns the fd number of read one.
>How-To-Repeat:
Run following program and get the output "ret:3, errno:0 3/4".
It should be "ret:0, errno:0 3/4.
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
int main(void) {
int fields[2];
int ret;
errno = 0;
ret = pipe2(fields, 0);
fprintf(stderr, "ret:%d, errno:%d %d/%d\n",ret,errno,fields[0], fields[1]);
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
From: "U.Nakamura" <usa@garbagecollect.jp>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/45545
Date: Tue, 01 Nov 2011 00:06:13 +0900
I've debugged this problem with Naruse-san, and wrote a patch.
Index: sys_descrip.c
===================================================================
RCS file: /cvs/cvsroot/src/sys/kern/sys_descrip.c,v
retrieving revision 1.22
diff -p -U 3 -r1.22 sys_descrip.c
--- sys_descrip.c 26 Jun 2011 16:42:42 -0000 1.22
+++ sys_descrip.c 31 Oct 2011 15:04:40 -0000
@@ -759,5 +759,7 @@ sys_pipe2(struct lwp *l, const struct sy
return error;
fd[0] = retval[0];
fd[1] = retval[1];
- return copyout(fd, SCARG(uap, fildes), sizeof(fd));
+ error = copyout(fd, SCARG(uap, fildes), sizeof(fd));
+ *retval = (error == 0) ? 0 : -1;
+ return error;
}
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/45545 CVS commit: src/sys/kern
Date: Mon, 31 Oct 2011 17:31:29 -0400
Module Name: src
Committed By: christos
Date: Mon Oct 31 21:31:29 UTC 2011
Modified Files:
src/sys/kern: sys_descrip.c
Log Message:
PR/45545 Yui NARUSE: pipe2's return value is wrong
To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/kern/sys_descrip.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Mon, 31 Oct 2011 22:33:18 +0000
State-Changed-Why:
Thank you for the patch! christos committed it.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.