I want to send a opened file descriptor between two different programs. So I am using ioctl
with named pipes
to do so. But there I am getting Inval
It looks like linux doesn't support I_SENDFD. The comments indicate that I_SENDFD
is in the documentation, but is not actually supported, and results in the error message you encountered. The wikipedia entry for STREAMS states the linux kernel does not have any support for streams. The wikipedia entry does point to a couple of third-party packages that could be used to add streams support, but LiS has not been ported to the 2.6 kernel, and OpenSS7 hasn't had any active development in 4 years.
However, linux does support something similar. This mechanism uses a special message type SCM_RIGHTS
to deliver a file descriptor over a UNIX domain socket with sendmsg
and obtained from recvmsg
. Examples can be found with a simple web search, a complete example seems to be from the book The Linux Programming Interface, with source for sending and receiving.