Since we no longer use closefds(), start cleaning up stray descriptors.
Start by making sure that any network sockets we create have the
close-on-exec flag set on them.
#include "client.h"
#include "h/mts.h"
#include "h/utils.h"
+#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
}
if (connect(sd, ai->ai_addr, ai->ai_addrlen) == 0) {
+ int flags;
+
freeaddrinfo(res);
+
+ flags = fcntl(sd, F_GETFD, 0);
+
+ if (flags != -1)
+ fcntl(sd, F_SETFD, flags | FD_CLOEXEC);
+
return sd;
}