From owner-freebsd-net Wed Aug 22 8:37:24 2001 Delivered-To: freebsd-net@freebsd.org Received: from srv1.cosmo-project.de (srv1.cosmo-project.de [213.83.6.106]) by hub.freebsd.org (Postfix) with ESMTP id A682D37B418 for ; Wed, 22 Aug 2001 08:37:00 -0700 (PDT) (envelope-from ticso@mail.cicely.de) Received: from mail.cicely.de (cicely20 [10.1.1.22]) by srv1.cosmo-project.de (8.11.0/8.11.0) with ESMTP id f7MFawA26044 for ; Wed, 22 Aug 2001 17:36:58 +0200 (CEST) Received: (from ticso@localhost) by mail.cicely.de (8.11.0/8.11.0) id f7MFasD23498 for freebsd-net@freebsd.org; Wed, 22 Aug 2001 17:36:54 +0200 (CEST) Date: Wed, 22 Aug 2001 17:36:53 +0200 From: Bernd Walter To: freebsd-net@freebsd.org Subject: Socket closed unexpectly. Message-ID: <20010822173653.A23491@cicely20.cicely.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i X-Operating-System: NetBSD cicely20.cicely.de 1.5 sparc Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org I have the following code: pid_t pid; int sv[2]; int val; char arg0[] = "someotherprog"; char arg1[] = VSTRING; char* arg[] = {arg0, arg1, 0}; socketpair(AF_UNIX, SOCK_STREAM, 0, sv); printf("socketpair returned %i,%i\n", sv[0], sv[1]); cox(sv[0]); cox(sv[1]); val = fcntl(sv[0], F_GETFL, 0); fcntl(sv[0], F_SETFL, val | O_NONBLOCK); pid = vfork(); if (pid == 0) { dup2(3, sv[1]); ncox(3); execve("/someotherprog", arg, 0); } close(sv[1]); cox() sets FD_CLOEXEC while ncox() deletes. 1. Problem: I need to clear FD_CLOEXEC on the descriptor that dup2 returned. Otherwise the the programm has fd 3 invalid. I wonder why dup2 did not clear it. 2. Problem: If I write(2) to sv[0] in the parent process I get an SIGPIPE. And read(2) on fd 3 in the child returns socket not connected. -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message