This is the mail archive of the
mailing list for the Cygwin project.
Re: Descriptor passing between process
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;
> struct msghdr msg;
> extern int errno;
> iov.iov_base = (char *) 0; /* no data to send */
> iov.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 );
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 Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:firstname.lastname@example.org
Red Hat, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html