Browse Source

[core] fdevent_dup_cloexec()

master
Glenn Strauss 8 months ago
parent
commit
2b4166fb74
  1. 10
      src/fdevent.c
  2. 1
      src/fdevent.h

10
src/fdevent.c

@ -522,6 +522,16 @@ int fdevent_socket_nb_cloexec(int domain, int type, int protocol) {
return fd;
}
int fdevent_dup_cloexec (int fd) {
#ifdef F_DUPFD_CLOEXEC
return fcntl(fd, F_DUPFD_CLOEXEC, 3);
#else
const int newfd = fcntl(fd, F_DUPFD, 3);
if (newfd >= 0) fdevent_setfd_cloexec(newfd);
return newfd;
#endif
}
#ifndef O_BINARY
#define O_BINARY 0
#endif

1
src/fdevent.h

@ -80,6 +80,7 @@ int fdevent_fcntl_set_nb_cloexec(int fd);
int fdevent_fcntl_set_nb_cloexec_sock(int fd);
int fdevent_socket_cloexec(int domain, int type, int protocol);
int fdevent_socket_nb_cloexec(int domain, int type, int protocol);
int fdevent_dup_cloexec(int fd);
int fdevent_open_cloexec(const char *pathname, int symlinks, int flags, mode_t mode);
int fdevent_mkstemp_append(char *path);
int fdevent_rename(const char *oldpath, const char *newpath);

Loading…
Cancel
Save