diff options
author | Werner Koch <wk@gnupg.org> | 2004-06-21 11:50:22 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2004-06-21 11:50:22 +0200 |
commit | 3571968f04ac5bbbbc2702478d1478330d2e2973 (patch) | |
tree | 08c4315ef2b754b8c3b786667ea983e90b0c307a /jnlib | |
parent | * sc-investigate.c (my_read_line): Renamed from read_line. (diff) | |
download | gnupg2-3571968f04ac5bbbbc2702478d1478330d2e2973.tar.xz gnupg2-3571968f04ac5bbbbc2702478d1478330d2e2973.zip |
(log_set_file): Do not close an old logstream if it
used to be stderr or stdout.
Diffstat (limited to 'jnlib')
-rw-r--r-- | jnlib/ChangeLog | 5 | ||||
-rw-r--r-- | jnlib/logging.c | 13 |
2 files changed, 12 insertions, 6 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog index e9f643774..e4df12a7f 100644 --- a/jnlib/ChangeLog +++ b/jnlib/ChangeLog @@ -1,3 +1,8 @@ +2004-06-21 Werner Koch <wk@g10code.com> + + * logging.c (log_set_file): Do not close an old logstream if it + used to be stderr or stdout. + 2004-05-05 Werner Koch <wk@gnupg.org> * logging.c (log_set_file): Oops, don't close if LOGSTREAM is NULL. diff --git a/jnlib/logging.c b/jnlib/logging.c index c75efaf85..f91339687 100644 --- a/jnlib/logging.c +++ b/jnlib/logging.c @@ -129,15 +129,15 @@ fun_writer (void *cookie_arg, const char *buffer, size_t size) struct fun_cookie_s *cookie = cookie_arg; /* Note that we always try to reconnect to the socket but print - error messages only the first time an error occured. IF + error messages only the first time an error occured. If RUNNING_DETACHED is set we don't fall back to stderr and even do - not print any error messages. This is needed becuase detached - processes often close stderr and my printing to fiel descriptor 2 + not print any error messages. This is needed because detached + processes often close stderr and by writing to file descriptor 2 we might send the log message to a file not intended for logging (e.g. a pipe or network connection). */ if (cookie->fd == -1) { - /* Note yet open or meanwhile closed due to an error. */ + /* Not yet open or meanwhile closed due to an error. */ struct sockaddr_un addr; size_t addrlen; @@ -256,13 +256,14 @@ log_set_file (const char *name) #endif /* Neither fopencookie nor funopen. */ /* We always need to print the prefix and the pid, so that the - server reading the socket can do something meanigful. */ + server reading the socket can do something meaningful. */ force_prefixes = 1; /* On success close the old logstream right now, so that we are really sure it has been closed. */ if (fp && logstream) { - fclose (logstream); + if (logstream != stderr && logstream != stdout) + fclose (logstream); logstream = NULL; } } |