Date: Wed, 22 Aug 2001 17:36:53 +0200 From: Bernd Walter <ticso@mail.cicely.de> To: freebsd-net@freebsd.org Subject: Socket closed unexpectly. Message-ID: <20010822173653.A23491@cicely20.cicely.de>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010822173653.A23491>