close socket fd if we can't connect it

This commit is contained in:
Daniel Barlow 2024-09-15 22:09:31 +01:00
parent 21eeb1671e
commit 9e5f2d663d
1 changed files with 1 additions and 0 deletions

View File

@ -24,6 +24,7 @@ int open_shipper_socket(char *pathname) {
if(fd >= 0) {
if(connect(fd, (struct sockaddr *) &sa, sizeof sa)) {
error(0, errno, "connect socket \"%s\"", pathname);
close(fd);
return -1;
}
int flags = fcntl(fd, F_GETFL);