On Fri, Jan 08, 2016 at 12:26:14PM +0700, Robert Elz wrote: > Date: Fri, 8 Jan 2016 11:22:28 +0800 (PHT) > From: Paul Goyette <p...@vps1.whooppee.com> > Message-ID: <pine.neb.4.64.1601081115270.22...@vps1.whooppee.com> > > | Is there a "supported" interface for detaching the file (or descriptor) > | from the process without closing it? > > Inside the kernel you want to follow the exact same procedure as would > be done by > > newfd = dup(oldfd); > close(oldfd); > > except instead of dup (and assigning to a newfd in the process) we > take the file reference and stick it in filemon. There's nothing > magic about this step. What magic there is (though barely worthy of > the title) would be in ensuring that filemon properly releases the file > when it is closing.
Years ago I added to gre(4) an ioctl that a user thread can use to delegate to the kernel a UDP socket that carries tunnel traffic. I think that that code should cover at least the dup(2) part of Robert's suggestion. Dave -- David Young dyo...@pobox.com Urbana, IL (217) 721-9981