Portable way to pass file descriptor between different processes

Your best bet is to try sending the file descriptor over a Unix domain socket. This is described in Stephens, and in a few places on the web, but I can dig up code for you if you ask nicely.

This will be pretty portable these days; a lot of the things considered “non-portable” way back when (such as mmap!) are extremely common now. If you need to be more portable than “most systems these days,” you’ve got a lot of interesting issues ahead of you, but possibly if you tell us more about what you’re doing and what platforms you’re working on (perhaps non-Unix POSIX platforms?) we might be able to help out.

Leave a Comment