From owner-freebsd-questions Sat Aug 21 15: 2:14 1999 Delivered-To: freebsd-questions@freebsd.org Received: from awfulhak.org (dynamic-31.max1-du-ws.dialnetwork.pavilion.co.uk [212.74.8.31]) by hub.freebsd.org (Postfix) with ESMTP id BBA6E14D33 for ; Sat, 21 Aug 1999 15:02:05 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from keep.lan.Awfulhak.org (root@keep.lan.Awfulhak.org [172.16.0.8]) by awfulhak.org (8.9.3/8.9.3) with ESMTP id WAA10334; Sat, 21 Aug 1999 22:47:26 +0100 (BST) (envelope-from brian@lan.awfulhak.org) Received: from keep.lan.Awfulhak.org (brian@localhost.lan.Awfulhak.org [127.0.0.1]) by keep.lan.Awfulhak.org (8.9.3/8.9.3) with ESMTP id WAA06688; Sat, 21 Aug 1999 22:50:22 +0100 (BST) (envelope-from brian@keep.lan.Awfulhak.org) Message-Id: <199908212150.WAA06688@keep.lan.Awfulhak.org> X-Mailer: exmh version 2.0.2 2/24/98 To: "Ronald F. Guilmette" Cc: Brian Somers , freebsd-questions@FreeBSD.ORG Subject: Re: Passing file descriptors via UNIX domain sockets In-reply-to: Your message of "Sat, 21 Aug 1999 13:01:31 PDT." <29451.935265691@monkeys.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 21 Aug 1999 22:50:22 +0100 From: Brian Somers Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG One caveat (I had to learn the hard way!) is that you *must* also pass some data in the oivec. If you don't, the descriptor isn't passed. Also, make sure you get an acknowledgement from the other side before closing the descriptor. If you close it while it's in transit, the other side will receive a closed descriptor as the open count isn't incremented as it's passed (in case the other side never does a recvmsg()). > In message <199908212022.VAA04816@keep.lan.Awfulhak.org>, you wrote: > > >Take a look at the ppp(8) code - specifically at > >bundle_ReceiveDatalink() and bundle_SendDatalink() in bundle.c. > > Yep! That's the ticket alrightee! That's exactly what I was looking > for. That code is most helpful as an example, and I am now gleefully > (and successfully) passing file descriptors! > > (I found the exact code you mentioned late last night, after I posted > my question to freebsd-questions. DUH! I guess I should have gone > grepping sources before I bothered everybody here. Sorry.) > > -- rfg > > P.S. The capability to pass open file descriptors between processes... > even between otherwise unrelated processes... is way cool! I can do some > neat things with this! Too bad the little pair of programs I wrote (just to > see if I could actually make this fd passing stuff work) doesn't actually > work under the Linux 2.2.7 kernel I have installed :-( even though it > works just fine on FreeBSD. :-) > > -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message