in watchman.c [194:221]
static int unix_stream_connect(const char *path, struct watchman_error *error)
{
struct sockaddr_un sa;
struct unix_sockaddr_context ctx;
if (unix_sockaddr_init(&sa, path, &ctx) < 0) {
return -1;
}
int fd = unix_stream_socket();
if (fd < 0) {
return -1;
}
if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
watchman_err(error, WATCHMAN_ERR_CONNECT, "Connect error %s",
strerror(errno));
if (unix_sockaddr_cleanup(&ctx, error)) {
error->code |= WATCHMAN_ERR_CWD;
}
close(fd);
return -1;
}
if (unix_sockaddr_cleanup(&ctx, error)) {
close(fd);
return -1;
}
return fd;
}