Create a free Team What is Teams? Learn more. Sharing file descriptors Ask Question. Asked 3 years, 10 months ago. Active 3 years, 10 months ago. Viewed 7k times. Does it rely on the kernel being mapped to the same numerical address range under each process? Improve this question.
Related: stackoverflow. Also related: unix. Add a comment. Active Oldest Votes. Improve this answer. Stephen Kitt Stephen Kitt k 45 45 gold badges silver badges bronze badges. Surprising as the sendmsg 2 manual makes no mention of this behaviour although recvmsg does.
I have over 5GB of memory not being used. But when I try to start the DB with the increased buffer parameter I get told. Shared memory. I have used semaphore mutex and still I'm getting segmentation fault when I write to the segment when other program is already RedHat Commands.
OpenSolaris Commands. Linux Commands. SunOS Commands. FreeBSD Commands. Full Man Repository. Advanced Search.
Contact Us. Forum Rules. Mark Forums Read. Thread Tools. View Public Profile for akalend. Find all posts by akalend. View Public Profile for Corona View Public Profile for abubacker.
Find all posts by abubacker. Show 5 more comments. Active Oldest Votes. This is the file z7. It isn't very interesting. It isn't even C code. But it is used by the fd-passing program to demonstrate that file descriptors can indeed be passed between sockets on occasion. I have not gone back and checked that all the additions were necessary. Alignment issues Nominal Animal suggests in a comment : May I suggest you modify the code to copy the descriptor int using memcpy instead of accessing the data directly?
And, with the fully working code, it does indeed seem to work. Extended testing would have the parent code read part of the file, and then demonstrate that the child codecontinues where the parent left off. That has not been coded, though. Andrew Domaszek 5 5 silver badges 17 17 bronze badges. Jonathan Leffler Jonathan Leffler k gold badges silver badges bronze badges. Thanks, it's working! The problem was lack of buffer for msg. Glad it's working for you. The receiving one worked with char mbuffer[1]; , but not without the struct iovec.
JonathanLeffler: May I suggest you modify the code to copy the descriptor int using memcpy instead of accessing the data directly?
It is not necessarily correctly aligned -- which is why the man page example also uses memcpy -- and there are many Linux architectures where unaligned int access causes problems up to SIGBUS signal killing the process. I also seem to recall historical issues on various OSes wrt. CMCDragonkai Yes, it is possible to pass multiple control messages in a single sendmsg call. On Linux, only one ancillary message of each type can be sent e.
On FreeBSD it is reportedly possible to send multiple messages of the same type in a single sendmsg ; I have not tested this. For a Linux example, see man7. Show 8 more comments. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
0コメント