I want to send a file descriptor of a tcp socket from process A to process B, so that process B can create another tcp socket with the same file descriptor.
the idea is exactly the same as passing file descriptors
the key function call is the following:
ioctl(fd, I_SENDFD, fd_to_send);
but it always returns EPERM /* Operation not permitted */
I verified the domain socket file descriptor fd is working, as I could send normal messages through that fd.
I don't know what's wrong. I googled, nobody seems to mention I_SENDFD has permission issue. I tried using "sudo" to run my programs. It still doesn't work.
I have also tried allowing everything for that file descriptorfcntl(fd_to_send, F_SETFL, S_IRWXU|S_IRUSR|S_IWUSR|S_IXUSR|S_IRWXG| S_IRGRP|S_IWGRP|S_IXGRP|S_IRWXO|S_IROTH|S_IWOTH|S_IXOTH);
doesn't work either.
how to fix?