| 78 | } |
| 79 | |
| 80 | int unix_stream_connect(const char *path, int disallow_chdir) |
| 81 | { |
| 82 | int fd = -1, saved_errno; |
| 83 | struct sockaddr_un sa; |
| 84 | struct unix_sockaddr_context ctx; |
| 85 | |
| 86 | if (unix_sockaddr_init(&sa, path, &ctx, disallow_chdir) < 0) |
| 87 | return -1; |
| 88 | fd = socket(AF_UNIX, SOCK_STREAM, 0); |
| 89 | if (fd < 0) |
| 90 | goto fail; |
| 91 | |
| 92 | if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) < 0) |
| 93 | goto fail; |
| 94 | unix_sockaddr_cleanup(&ctx); |
| 95 | return fd; |
| 96 | |
| 97 | fail: |
| 98 | saved_errno = errno; |
| 99 | if (fd != -1) |
| 100 | close(fd); |
| 101 | unix_sockaddr_cleanup(&ctx); |
| 102 | errno = saved_errno; |
| 103 | return -1; |
| 104 | } |
| 105 | |
| 106 | int unix_stream_listen(const char *path, |
| 107 | const struct unix_stream_listen_opts *opts) |
no test coverage detected