#include "sd-daemon.h"
#include "alloc-util.h"
+#include "errno-util.h"
#include "escape.h"
#include "fd-util.h"
#include "log.h"
#include "string-util.h"
#include "strv.h"
#include "terminal-util.h"
+#include "util.h"
static char** arg_listen = NULL;
static bool arg_accept = false;
except[fd] = fd;
log_close();
- close_all_fds(except, 3 + n);
+ r = close_all_fds(except, 3 + n);
+ if (r < 0)
+ return log_error_errno(r, "Failed to close all file descriptors: %m");
}
/** Note: we leak some fd's on error here. I doesn't matter
_cleanup_close_ int fd_accepted = -1;
fd_accepted = accept4(fd, NULL, NULL, 0);
- if (fd_accepted < 0)
+ if (fd_accepted < 0) {
+ if (ERRNO_IS_ACCEPT_AGAIN(errno))
+ return 0;
+
return log_error_errno(errno, "Failed to accept connection on fd:%d: %m", fd);
+ }
- getsockname_pretty(fd_accepted, &local);
- getpeername_pretty(fd_accepted, true, &peer);
+ (void) getsockname_pretty(fd_accepted, &local);
+ (void) getpeername_pretty(fd_accepted, true, &peer);
log_info("Connection from %s to %s", strna(peer), strna(local));
return fork_and_exec_process(name, argv, envp, fd_accepted);