diff --git a/src/util-io.h b/src/util-io.h index 21d5d81..0ea7d63 100644 --- a/src/util-io.h +++ b/src/util-io.h @@ -223,7 +223,8 @@ xconnect(const char *path) if (!xsnprintf(addr.sun_path, sizeof(addr.sun_path), "%s", path)) return -EINVAL; - int sockfd = xerrno(SYSCALL(socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0))); + _cleanup_close_ int sockfd = + xerrno(SYSCALL(socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0))); if (sockfd < 0) return sockfd; @@ -231,7 +232,7 @@ xconnect(const char *path) if (rc < 0) return rc; - return sockfd; + return steal_fd(&sockfd); } /**