Hacker News new | past | comments | ask | show | jobs | submit login

Another real-world use case is zero-copy interprocess communication, as in the Wayland protocol <https://wayland-book.com/surfaces/shared-memory.html>. It can also be combined with sealed files <https://lwn.net/Articles/593918/> to avoid some of the pitfalls of shared memory.



Wayland (& gstreamer) uses fd-passing to implement zero copy of graphics-textures/video frames across process. this is typically used in conjunction with buffers allocated by a mechanism like dmabuf which allocates a memory area and provides a fd associated with it to userland. this (translated) fd can be used by the other process to map the same region of memory.


I don't follow. How can file descriptors be passed through a shared memory to another process and remain valid in its context?

Assuming it's not Windows, where it is possible to explicitly clone a handle for a specific process.


The linked code example doesn't seem to do fd passing, but I guess the use case of fd passing in shared memory context would be the other way around: passing fd's that point to shared memory. The shared memory could then be mmap'ed using the passed fd as the handle.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: