diff options
Diffstat (limited to 'sway/log.c')
-rw-r--r-- | sway/log.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -2,6 +2,8 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <fcntl.h> +#include <unistd.h> int colored = 1; int v = 0; @@ -15,6 +17,16 @@ const char *verbosity_colors[] = { void init_log(int verbosity) { v = verbosity; + /* set FD_CLOEXEC flag to prevent programs called with exec to write into + * logs */ + int i, flag; + int fd[] = { STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO }; + for (i = 0; i < 3; ++i) { + flag = fcntl(fd[i], F_GETFD); + if (flag != -1) { + fcntl(fd[i], F_SETFD, flag | FD_CLOEXEC); + } + } } void sway_log_colors(int mode) { |