>> +#ifdef HAVE_SYSTEMD
>> + /* Read the number of sockets passed through by systemd. */
>> + systemd_socket = sd_listen_fds(0);
>
> Isn't it prudent to test the socket descriptor for validity? What if
> it isn't a socket, for example?
Agreed. I'm thinking about trying getsockname as a test for validity as
this should also ensure that the socket is already bound.