diff options
author | 2012-05-30 15:01:21 +0000 | |
---|---|---|
committer | 2012-05-30 15:01:21 +0000 | |
commit | f5639e04f49c9d41a6040a3f0e5c9d81999715f5 (patch) | |
tree | ce3430813ff56915e2de714dddf06d908d419581 | |
parent | silence warning, as noticed with eric and landry (diff) | |
download | wireguard-openbsd-f5639e04f49c9d41a6040a3f0e5c9d81999715f5.tar.xz wireguard-openbsd-f5639e04f49c9d41a6040a3f0e5c9d81999715f5.zip |
Do not use stderr for log file and don't call log_close when not needed.
-rw-r--r-- | usr.bin/tmux/log.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c index 73cffde98de..4e021e837be 100644 --- a/usr.bin/tmux/log.c +++ b/usr.bin/tmux/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.7 2012/05/25 08:28:10 nicm Exp $ */ +/* $OpenBSD: log.c,v 1.8 2012/05/30 15:01:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -28,7 +28,7 @@ #include "tmux.h" /* Log file, if needed. */ -FILE *log_file = stderr; +FILE *log_file; /* Debug level. */ int log_level = 0; @@ -63,7 +63,7 @@ log_open(int level, const char *path) void log_close(void) { - if (log_file != stderr) + if (log_file != NULL) fclose(log_file); event_set_log_callback(NULL); @@ -75,6 +75,9 @@ log_vwrite(const char *msg, va_list ap) { char *fmt; + if (log_file == NULL) + return; + if (asprintf(&fmt, "%s\n", msg) == -1) exit(1); if (vfprintf(log_file, fmt, ap) == -1) diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index fd8b7b5d633..6a7692ced6e 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.109 2012/05/25 08:28:10 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.110 2012/05/30 15:01:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -70,7 +70,6 @@ logfile(const char *name) { char *path; - log_close(); if (debug_level > 0) { xasprintf(&path, "tmux-%s-%ld.log", name, (long) getpid()); log_open(debug_level, path); |