From a1a559e25a19726b3a62267feb5e89bad2fcd01e Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 4 Jan 2017 01:32:44 -0600 Subject: Some lib fixes: mark xvfork() noinline, make xsendfile() return bytes copied, make xsocket()'s returned fd CLOEXEC. --- lib/net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/net.c') diff --git a/lib/net.c b/lib/net.c index 1a46a5a9..df2551f7 100644 --- a/lib/net.c +++ b/lib/net.c @@ -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); -- cgit v1.2.3