aboutsummaryrefslogtreecommitdiff
path: root/sway/log.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-08-13 11:00:00 -0400
committerDrew DeVault <sir@cmpwn.com>2015-08-13 11:00:00 -0400
commit94e81fd64c4f63815047fa1ad895cade9afa8bd4 (patch)
tree9770eded52cae4f9d3d033123e1470d7873624c5 /sway/log.c
parent9475548f2426b3892a6d14961af36edc49b72182 (diff)
parent0a205776d7023cb8dea0d62994dff7b01d19dbcf (diff)
Merge pull request #23 from taiyu-len/master
moving things around + statics + forking + exec cleanup + fixed cmd_focus return + keep exec programs out of logs
Diffstat (limited to 'sway/log.c')
-rw-r--r--sway/log.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sway/log.c b/sway/log.c
index 188461eb..b9048b34 100644
--- a/sway/log.c
+++ b/sway/log.c
@@ -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) {