mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
(log_set_file): Do not close an old logstream if it
used to be stderr or stdout.
This commit is contained in:
parent
8b3cf19e24
commit
3571968f04
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user