Module Name:    src
Committed By:   kre
Date:           Tue Nov 12 03:06:58 UTC 2024

Modified Files:
        src/lib/librumphijack: hijack.c

Log Message:
dup2() must (except when there's an error) return the new fd.   Not 0
unless that happens to be the new fd.

Fixes tests/lib/librumphijack/t_sh/redirect


To generate a diff of this commit:
cvs rdiff -u -r1.140 -r1.141 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.140 src/lib/librumphijack/hijack.c:1.141
--- src/lib/librumphijack/hijack.c:1.140	Fri Aug 16 04:23:31 2024
+++ src/lib/librumphijack/hijack.c	Tue Nov 12 03:06:58 2024
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.140 2024/08/16 04:23:31 ozaki-r Exp $	*/
+/*      $NetBSD: hijack.c,v 1.141 2024/11/12 03:06:58 kre Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include <rump/rumpuser_port.h>
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.140 2024/08/16 04:23:31 ozaki-r Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.141 2024/11/12 03:06:58 kre Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1886,7 +1886,7 @@ dup2(int oldd, int newd)
 		 */
 		op_close(newd);
 		setdup2(newd, fd_host2rump(oldd));
-		rv = 0;
+		rv = newd;
 	} else {
 		host_dup2 = syscalls[DUALCALL_DUP2].bs_host;
 		if (rumpclient__closenotify(&newd, RUMPCLIENT_CLOSE_DUP2) == -1)

Reply via email to