#include <sys/types.h>
#include <unistd.h>
-#include <common/common.h>
-#include <common/compat/errno.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/fd-handle.h>
+#include <common/common.hpp>
+#include <common/compat/errno.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/fd-handle.hpp>
-#include "unix.h"
+#include "unix.hpp"
/*
* Connect to unix socket using the path name.
/* Shutdown receptions and transmissions */
ret = shutdown(sock, SHUT_RDWR);
if (ret < 0) {
- PERROR("shutdown");
+ /*
+ * The socket is already disconnected, don't error out.
+ * This doesn't happen on Linux, but it does on FreeBSD, see:
+ * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227259
+ */
+ if (errno == ENOTCONN) {
+ ret = 0;
+ } else {
+ PERROR("shutdown");
+ }
}
closeret = close(sock);