aboutsummaryrefslogtreecommitdiffstats
path: root/jnlib
diff options
context:
space:
mode:
Diffstat (limited to 'jnlib')
-rw-r--r--jnlib/ChangeLog5
-rw-r--r--jnlib/logging.c24
-rw-r--r--jnlib/t-support.c1
3 files changed, 18 insertions, 12 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index 05c8e98a5..8c12f5fc5 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-25 Werner Koch <[email protected]>
+
+ * logging.c (fun_closer): Never close fd 2.
+ (set_file_fd): Close logstream early.
+
2009-02-25 Werner Koch <[email protected]>
* logging.c (get_tid_callback): New.
diff --git a/jnlib/logging.c b/jnlib/logging.c
index b06361980..fb41b45ef 100644
--- a/jnlib/logging.c
+++ b/jnlib/logging.c
@@ -218,7 +218,7 @@ fun_closer (void *cookie_arg)
{
struct fun_cookie_s *cookie = cookie_arg;
- if (cookie->fd != -1)
+ if (cookie->fd != -1 && cookie->fd != 2)
close (cookie->fd);
jnlib_free (cookie);
log_socket = -1;
@@ -239,6 +239,15 @@ set_file_fd (const char *name, int fd)
struct fun_cookie_s *cookie;
#endif
+ /* Close an open log stream. */
+ if (logstream)
+ {
+ if (logstream != stderr && logstream != stdout)
+ fclose (logstream);
+ logstream = NULL;
+ }
+
+ /* Figure out what kind of logging we want. */
if (name && !strcmp (name, "-"))
{
name = NULL;
@@ -256,6 +265,7 @@ set_file_fd (const char *name, int fd)
want_socket = 0;
}
+ /* Setup a new stream. */
#ifdef USE_FUNWRITER
cookie = jnlib_xmalloc (sizeof *cookie + (name? strlen (name):0));
strcpy (cookie->name, name? name:"");
@@ -310,15 +320,7 @@ set_file_fd (const char *name, int fd)
#endif /*!USE_FUNWRITER*/
- /* On success close the old logstream right now, so that we are
- really sure it has been closed. */
- if (fp && logstream)
- {
- if (logstream != stderr && logstream != stdout)
- fclose (logstream);
- logstream = NULL;
- }
-
+ /* On error default to stderr. */
if (!fp)
{
if (name)
@@ -333,8 +335,6 @@ set_file_fd (const char *name, int fd)
else
setvbuf (fp, NULL, _IOLBF, 0);
- if (logstream && logstream != stderr && logstream != stdout)
- fclose (logstream);
logstream = fp;
/* We always need to print the prefix and the pid for socket mode,
diff --git a/jnlib/t-support.c b/jnlib/t-support.c
index 126104846..756c54c7f 100644
--- a/jnlib/t-support.c
+++ b/jnlib/t-support.c
@@ -120,6 +120,7 @@ gcry_free (void *a)
int
gpg_err_code_from_errno (int err)
{
+ (void)err;
assert (!"stub function");
return -1;
}