start-stop-daemon: set fds to CLOEXEC instead of closing
Set file descriptors to CLOEXEC instead of closing them before exec, similar to what we do in supervise-daemon. Use the share cloexec_fds_from() helper for this. closefrom() is no longer used so remove the test.
This commit is contained in:
parent
c199c5cf6e
commit
e447562aaa
@ -195,9 +195,6 @@ if cc.compiles(malloc_attribute_test, name : 'malloc attribute with arguments')
|
|||||||
add_project_arguments('-DHAVE_MALLOC_EXTENDED_ATTRIBUTE', language: 'c')
|
add_project_arguments('-DHAVE_MALLOC_EXTENDED_ATTRIBUTE', language: 'c')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if cc.has_function('closefrom', prefix: '#define _GNU_SOURCE\n#include <unistd.h>')
|
|
||||||
add_project_arguments('-DHAVE_CLOSEFROM', language: 'c')
|
|
||||||
endif
|
|
||||||
if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd.h>')
|
if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd.h>')
|
||||||
add_project_arguments('-DHAVE_CLOSE_RANGE', language: 'c')
|
add_project_arguments('-DHAVE_CLOSE_RANGE', language: 'c')
|
||||||
endif
|
endif
|
||||||
|
@ -1098,12 +1098,7 @@ int main(int argc, char **argv)
|
|||||||
|| rc_yesno(getenv("EINFO_QUIET")))
|
|| rc_yesno(getenv("EINFO_QUIET")))
|
||||||
dup2(stderr_fd, STDERR_FILENO);
|
dup2(stderr_fd, STDERR_FILENO);
|
||||||
|
|
||||||
#ifdef HAVE_CLOSEFROM
|
cloexec_fds_from(3);
|
||||||
closefrom(3);
|
|
||||||
#else
|
|
||||||
for (i = getdtablesize() - 1; i >= 3; --i)
|
|
||||||
close(i);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (scheduler != NULL) {
|
if (scheduler != NULL) {
|
||||||
int scheduler_index;
|
int scheduler_index;
|
||||||
|
Loading…
Reference in New Issue
Block a user