How can I pass a file descriptor to another process?

1

I recently read a Peter Hutterer post explaining about a new protocol called inputfd that is intended to forward a file descriptor directly to other processes without the composer's interaction.

I was curious, how is it possible to pass a file descriptor from one process to another?

Could you show a minimal example of code that does this?

    
asked by anonymous 17.04.2017 / 20:10

1 answer

1

In the UNIX (and Linux) environment the process of passing a file descriptor between any processes is well known and uses the "sendmsg" function between local sockets (AF_UNIX or AF_LOCAL family). This SOen page has several examples of how to do it.

The first time I saw this example was in one of W. Richard Stevens's books, which are the basic reference for programming in the UNIX environment. Unfortunately on Amazon only one of them is available on the Kindle, here . (The 3rd issue is from another author because WRS died about 15 years ago.)

    
24.04.2017 / 15:45