Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Thu, 24 Jan 2002 16:33:52 +0100 From: Corinna Vinschen To: cygwin Subject: Re: Descriptor passing between process Message-ID: <20020124163352.Z11608@cygbert.vinschen.de> Mail-Followup-To: cygwin References: <002401c1a3f4$0b77e8c0$010310ac AT lyoncleitienne> <20020123120701 DOT A11608 AT cygbert DOT vinschen DOT de> <8181418335 DOT 20020124161420 AT logos-m DOT ru> <20020124142156 DOT Y11608 AT cygbert DOT vinschen DOT de> <4183271981 DOT 20020124164513 AT logos-m DOT ru> <000901c1a4e1$d967f430$010310ac AT lyoncleitienne> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000901c1a4e1$d967f430$010310ac@lyoncleitienne> User-Agent: Mutt/1.3.22.1i On Thu, Jan 24, 2002 at 03:17:23PM +0100, Christophe LEITIENNE wrote: > I found a piece of code that doesn't use all this stuff. Could it work (I > haven't tried yet) ? > > int sendfd(sockfd, fd) > int sockfd; /* UNIX domain socket to pass descriptor on */ > int fd; /* the actual fd value to pass */ > { > struct iovec iov[1]; > struct msghdr msg; > extern int errno; > > iov[0].iov_base = (char *) 0; /* no data to send */ > iov[0].iov_len = 0; > msg.msg_iov = iov; > msg.msg_iovlen = 1; > msg.msg_name = (caddr_t) 0; > msg.msg_accrights = (caddr_t) &fd; /* address of descriptor */ > msg.msg_accrightslen = sizeof(fd); /* pass 1 descriptor */ > > if (sendmsg(sockfd, &msg, 0) < 0) > return( (errno > 0) ? errno : 255 ); > > return(0); > } This isn't supported. Control structure passing doesn't work at all with the current implementation. Btw., the above source code won't work on Linux, too. First of all, the msg_accrights and msg_accrightslen members doesn't exist in the msghdr struct (they are called msg_control and msg_controllen) and second, file descriptors in one process have no meaning in another process, except it's parent or child of the calling process, coincidentally. That's somewhat dangerous. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Developer mailto:cygwin AT cygwin DOT com Red Hat, Inc. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/