chiark
/
gitweb
/
~ian
/
secnet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fds: Provide cloexec() and use it in udp.c and tun.c
[secnet.git]
/
util.c
diff --git
a/util.c
b/util.c
index 094870ff213cbc41c9f011aa1b316f646ee30992..fc6f6264cf433ba84211858df529b986b377b714 100644
(file)
--- a/
util.c
+++ b/
util.c
@@
-162,6
+162,13
@@
int32_t write_mpbin(MP_INT *a, uint8_t *buffer, int32_t buflen)
return i;
}
return i;
}
+void setcloexec(int fd) {
+ int r=fcntl(fd, F_GETFD);
+ if (r<0) fatal_perror("fcntl(,F_GETFD) failed");
+ r=fcntl(fd, F_SETFD, r|FD_CLOEXEC);
+ if (r<0) fatal_perror("fcntl(,F_SETFD,|FD_CLOEXEC) failed");
+}
+
static const char *phases[NR_PHASES]={
"PHASE_INIT",
"PHASE_GETOPTS",
static const char *phases[NR_PHASES]={
"PHASE_INIT",
"PHASE_GETOPTS",