Questions about sendmsg to pass fd between processes
by yeliu0218 from LinuxQuestions.org on (#5PSP4)
Hi all,
I have 3 processes, let's say A, B and C. I want to pass a file descriptor fd from A to C, but it has to pass B first, so I use sendmsg and set flag SCM_RIGHTS to send the message from A to B, so that fd is valid when it reaches B. Then I use the same routine again to send the message from B to C. In short, it is like:
A --------------sendmsg, SCM_RIGHTS-------------------> B -----------------sendmsg, SCM_RIGHTS-----------------> C
Actually it works, that C can open the fd originated from A successfully, however, after
maybe thousands of this operation, B/C randomly crashes, and there is no hint of where the crash happens.
If I unset SCM_RIGHTS from B to C, then the crash disappear, but then the fd from B to C is not valid any more.
Anyone has had similar experience? Can anyone help me with it?
Thank you very much!
I have 3 processes, let's say A, B and C. I want to pass a file descriptor fd from A to C, but it has to pass B first, so I use sendmsg and set flag SCM_RIGHTS to send the message from A to B, so that fd is valid when it reaches B. Then I use the same routine again to send the message from B to C. In short, it is like:
A --------------sendmsg, SCM_RIGHTS-------------------> B -----------------sendmsg, SCM_RIGHTS-----------------> C
Actually it works, that C can open the fd originated from A successfully, however, after
maybe thousands of this operation, B/C randomly crashes, and there is no hint of where the crash happens.
If I unset SCM_RIGHTS from B to C, then the crash disappear, but then the fd from B to C is not valid any more.
Anyone has had similar experience? Can anyone help me with it?
Thank you very much!