Switch from dup() + fcntl(F_SETFL, FD_CLOEXEC) to fcntl(F_DUPFD_CLOEXEC) to save a second syscall.
This commit is contained in:
@@ -133,8 +133,8 @@ bool opts_add_exec_send(char *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool opts_add_stdin(char __attribute__((unused)) *arg) {
|
bool opts_add_stdin(char __attribute__((unused)) *arg) {
|
||||||
int fd = dup(0);
|
int fd = fcntl(0, F_DUPFD_CLOEXEC, 0);
|
||||||
assert(!fcntl(fd, F_SETFD, FD_CLOEXEC));
|
assert(fd >= 0);
|
||||||
file_fd_new(fd, receive_flow, NULL);
|
file_fd_new(fd, receive_flow, NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -144,8 +144,8 @@ bool opts_add_stdout(char *arg) {
|
|||||||
if (!serializer) {
|
if (!serializer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int fd = dup(1);
|
int fd = fcntl(1, F_DUPFD_CLOEXEC, 0);
|
||||||
assert(!fcntl(fd, F_SETFD, FD_CLOEXEC));
|
assert(fd >= 0);
|
||||||
file_fd_new(fd, send_flow, serializer);
|
file_fd_new(fd, send_flow, serializer);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user