fd-close-on-exec.c revision 76b43e4417bab52e913da39b5f5bc2a130d3f149
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi/* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi flags = set ? (flags | FD_CLOEXEC) : (flags & ~FD_CLOEXEC);
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomivoid fd_debug_verify_leaks(int first_fd, int last_fd)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi if (fcntl(first_fd, F_GETFD, 0) == -1 && errno == EBADF)
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi if (net_getsockname(first_fd, &addr, &port) == 0) {
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi if (net_getpeername(first_fd, &raddr, &rport) < 0) {
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi /* OSX workaround: gettimeofday() calls shm_open()
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi internally and the fd won't get closed on exec.
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi We'll just skip all ino/dev=0 files and hope they
316cbe323513a0f20d1cf519fe9405e231d633e2Aki Tuomi weren't anything else. */