From owner-freebsd-questions Fri Feb 28 16:18:42 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id QAA28142 for questions-outgoing; Fri, 28 Feb 1997 16:18:42 -0800 (PST) Received: from nyx.pr.mcs.net (nyx.pr.mcs.net [204.95.55.81]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id QAA28133 for ; Fri, 28 Feb 1997 16:18:32 -0800 (PST) Received: from nyx.pr.mcs.net (localhost [127.0.0.1]) by nyx.pr.mcs.net (8.8.5/8.8.4) with ESMTP id SAA03198 for ; Fri, 28 Feb 1997 18:18:15 -0600 (CST) Message-Id: <199703010018.SAA03198@nyx.pr.mcs.net> X-Mailer: exmh version 2.0beta 12/23/96 To: questions@freebsd.org Subject: dup(2) usage question... Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 28 Feb 1997 18:18:13 -0600 From: Chris Csanady Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk If I dup a file descriptor, and close one, both will be closed, right? Anyway, what I would like to do is just rename a file descriptor, and then copy another one to the original. It doesnt seem to be working, so I assume it is being closed. Is there a way around this? Essentially, I'm trying to to squeeze a layer in to do intermediate processing on data from a fd of another (forked) program. Something like this: fd=dup(4); socketpair(PF_LOCAL, SOCK_STREAM, 0, sv); dup2(sv[1], 4); Is this possible? If not, is there another way I may acheive this effect? Thanks, Chris Csanady