Some tricks in passing file descriptors through unix domain socket

Passing file descriptors through unix domain socket is well-known. But there still have some tricks in implementation. I spent one day to deal with it in Mac OS X by digging into xnu source. How to pass multiple file descriptors in one sendmsg() call? Simple. Put all file descriptors one by one after struct cmsghdr.…