forked from external/yambar
module/script: close all unrelated FDs
While most FDs are CLOEXEC, not all are. For example, other script modules’ re-direction pipes.
This commit is contained in:
parent
31f6a4a6a0
commit
aa34925f54
1 changed files with 10 additions and 0 deletions
|
@ -479,6 +479,16 @@ run(struct module *mod)
|
||||||
close(comm_pipe[1]);
|
close(comm_pipe[1]);
|
||||||
comm_pipe[1] = -1;
|
comm_pipe[1] = -1;
|
||||||
|
|
||||||
|
/* Close *all* other FDs */
|
||||||
|
for (int i = STDERR_FILENO + 1; i < 65536; i++) {
|
||||||
|
if (i == exec_pipe[1]) {
|
||||||
|
/* Needed for error reporting. Automatically closed
|
||||||
|
* when execvp() succeeds */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
close(i);
|
||||||
|
}
|
||||||
|
|
||||||
execvp(m->path, argv);
|
execvp(m->path, argv);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
Loading…
Add table
Reference in a new issue