diff options
Diffstat (limited to 'lib/net.c')
-rw-r--r-- | lib/net.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -5,6 +5,8 @@ int xsocket(int domain, int type, int protocol) int fd = socket(domain, type, protocol); if (fd < 0) perror_exit("socket %x %x", type, protocol); + fcntl(fd, F_SETFD, FD_CLOEXEC); + return fd; } @@ -35,7 +37,7 @@ int xconnect(char *host, char *port, int family, int socktype, int protocol, fd = (ai->ai_next ? socket : xsocket)(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (!connect(fd, ai->ai_addr, ai->ai_addrlen)) break; - else if (!ai2->ai_next) perror_exit("connect"); + else if (!ai->ai_next) perror_exit("connect"); close(fd); } freeaddrinfo(ai2); |