Article 5PSP4 Questions about sendmsg to pass fd between processes

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!latest?d=yIl2AUoC8zA latest?i=1RUUm49gfRE:O4xhhe_umOo:F7zBnMy latest?i=1RUUm49gfRE:O4xhhe_umOo:V_sGLiP latest?d=qj6IDK7rITs latest?i=1RUUm49gfRE:O4xhhe_umOo:gIN9vFw1RUUm49gfRE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments