Enrico Scholz <enrico.scholz@...-chemnitz.de> wrote:
> +#ifdef USE_CLOEXEC
Is there a reason why you don't you just include <fcntl.h> and test
#ifdef FD_CLOEXEC ?
> - if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
> + if ((sock = socket_cloexec(AF_UNIX, SOCK_STREAM, 0)) == -1) {
> mg_log(LOG_ERR, "spamd socket failed: %s", strerror(errno));
> return -1;
I think I would rather do something like this:
if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
mg_log(LOG_ERR, "spamd socket failed: %s", strerror(errno));
return -1;
}
SET_CLOEXEC(sock);
With
#ifdef FD_CLOEXEC
#define SET_CLOEXEC(fd) do { \
int flags = fcntl((fd), F_GETFD, 0); \
\
if (flags != -1) \
(void)fcntl((fd, F_SETFD, flags|FD_CLOEXEC); \
} while (0 /* CONSTCOND */);
#else /* FD_CLOEXEC */
#define SET_CLOEXEC(fd)
#endif /* FD_CLOEXEC */
--
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu@...Message
Re: [milter-greylist] [PATCH] Set CLOEXEC flags for sockets
2010-06-10 by manu@netbsd.org
Attachments
- No local attachments were found for this message.