On Fri, Nov 06, 2020 at 08:30:50PM +0100, Markus Wichmann wrote:
> Hi all,
>
> I was reading musl's syslog source code today for unrelated reasons, and
> saw that it is using connect() to set the destination. And it has some
> code to deal with connection failures. But why? I see the syslog socket
> is a datagram socket, so I thought sendto() with destination address
> means the same thing as connect() and send(), with the difference that
> it is one less syscall that can fail and no connection errors to handle.
> I tried finding information about the semantics of connect() on a UNIX
> datagram socket, but failed to find anything useful.
It's there so the process can chroot, move into a namespace/container,
etc. after calling openlog without losing the ability to do logging.
Rich