Sometimes Weston (or any Wayland compositor really) would become unresponsive (whole UI frozen, mouse doesn't move) when a client (desktop app) became unresponsive. After some testing with procstat, the cause was found: sendmsg. Turns out libwayland-server was telling the kernel to not block on sendmsg, but the kernel wasn't listening.
sendmsg(connection->fd, &msg, MSG_NOSIGNAL | MSG_DONTWAIT);
As a workaround MSG_NBIO can be used, but according to the comment it's intended for some fifo stuff. Let's support the correct constant that other operating systems support, e.g. OpenBSD does support it.