So I have an AF_UNIX/SOCK_SEQPACKET socket on Linux. When reading from it, how do I distinguish a zero-length datagram from EOF on read() or recv() (and friends) in a safe, minimal and correct way? Ideas?
looking through the kernel: __sys_recvmmsg() -> ___sys_recvmsg() -> sock_recvmsg() -> sock_recvmsg_nosec() -> unix_seqpacket_recvmsg() -> unix_dgram_recvmsg() -> scm_recv(), if ->msg_control is NULL, calls scm_destroy() and signals that to userspace with MSG_CTRUNC if possible
-
-
scm_destroy() -> __scm_destroy() -> fput() loop
-
so you only have to deal with FD flooding if there is some other type of control message you do want to receive (like SCM_CREDENTIALS)
- 1 more reply
New conversation -
-
-
kudos for reading the kernel code
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.