commit - 8307a7c8a20d43ed32440d3a15197e4f5a804022
commit + ee0aac2f009a841246854bc189070f07803d0d2e
blob - 10acae1b1d3ecb0e2c6fac34c7fd1f50b483b38b
blob + b2cba8137f48f2e155021927aea8685178e2d619
--- control.c
+++ control.c
int fd;
mode_t old_umask;
- if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
- 0)) == -1) {
+ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
warn("%s: socket", __func__);
return (-1);
}
+ if (!mark_nonblock_cloexec(fd)) {
+ close(fd);
+ return (-1);
+ }
+
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
return;
len = sizeof(sun);
- if ((connfd = accept4(listenfd, (struct sockaddr *)&sun, &len,
- SOCK_CLOEXEC | SOCK_NONBLOCK)) == -1) {
+ if ((connfd = accept(listenfd, (struct sockaddr *)&sun, &len)) == -1) {
/*
* Pause accept if we are out of file descriptors, or
* libevent will haunt us here too.
return;
}
+ if (!mark_nonblock_cloexec(connfd)) {
+ message("%s: mark_nonblock_cloexec: %s", __func__,
+ strerror(errno));
+ close(connfd);
+ return;
+ }
+
if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
message("%s: calloc: %s", __func__, strerror(errno));
close(connfd);
blob - faa6df63aa90f545848a3d44d2f14cdba3239fd0
blob + 588673966051ca334bb6556f4e9054308ee8bc64
--- include/utils.h
+++ include/utils.h
#ifndef UTILS_H
#define UTILS_H
-int mark_nonblock(int);
+int mark_nonblock_cloexec(int);
int has_suffix(const char *, const char *);
int unicode_isspace(uint32_t);
blob - 35e3674d618b8b5ad01dd54d45f883e9fde01359
blob + 48ce206255dcef21d57c0556dcd570f965041aea
--- net.c
+++ net.c
req->p = req->p->ai_next;
goto again;
} else {
- mark_nonblock(req->fd);
+ mark_nonblock_cloexec(req->fd);
if (connect(req->fd, req->p->ai_addr, req->p->ai_addrlen) == 0)
goto done;
yield_w(req, try_to_connect, NULL);
blob - d36b92c69e0f2fb8092ed347f7bc3ccab891c9c3
blob + a78de2d3db7f7b2d79d10c46adc1229c634d5ca7
--- utils.c
+++ utils.c
#include "utils.h"
int
-mark_nonblock(int fd)
+mark_nonblock_cloexec(int fd)
{
int flags;
return 0;
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
return 0;
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
+ return 0;
return 1;
}