i want to send an fd to another process …
does anyone know a library that can send fds over a socket, like pythons socket.send_fds/recv_fds ?
i want to send an fd to another process …
does anyone know a library that can send fds over a socket, like pythons socket.send_fds/recv_fds ?
At the moment there isn’t a nice zig std wrapper around the CMSG macros. But there are some links to some other users implementations here: https://codeberg.org/ziglang/zig/issues/30629
Note that they may need patching depending on the zig version you’re using.
I’ve recently submitted some patches fixing the cmsghdr and msghdr structs on non-Linux platforms. I’m now trying to refine the abstraction I’ve built around them so that I can submit it as a proposed solution to this particular issue. Right now I just have a nice while (cmsg.iter()) interface that works for FreeBSD and SCM_RIGHTS, but I’ve hacked some alignments for that.
It looks like there has been a bit of movement towards this from several people lately - maybe 0.18?
Here is what I threw together: https://pastebin.com/raw/E0PCkpDt
Note that I have two days of Zig experience
I chose the wrong one of my projects to port for learning apparently.
If you are not linking libc you can use -I/usr/include. Also, Zig will ensure there is an unnecessary null terminator in the address, so make sure to add one if you are interfacing with another language.