summaryrefslogtreecommitdiffstats
path: root/jnlib
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2005-02-03 14:20:57 +0100
committerWerner Koch <wk@gnupg.org>2005-02-03 14:20:57 +0100
commit625bafa4dacb7f20cc2c11697048ccafbb6c180a (patch)
treea1af31090ea994812814d08a12b13b7d901a4c42 /jnlib
parentThis commit was manufactured by cvs2svn to create branch (diff)
downloadgnupg2-625bafa4dacb7f20cc2c11697048ccafbb6c180a.tar.xz
gnupg2-625bafa4dacb7f20cc2c11697048ccafbb6c180a.zip
Forgot to commit the recent fixed to scd and logging - doing it now
Diffstat (limited to 'jnlib')
-rw-r--r--jnlib/ChangeLog5
-rw-r--r--jnlib/logging.c41
2 files changed, 18 insertions, 28 deletions
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index a879254ae..0c82c8724 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,8 @@
+2005-01-19 Werner Koch <wk@g10code.com>
+
+ * logging.c (fun_writer): Don't fallback to stderr. Print to
+ stderr only if connected to a tty.
+
2004-12-20 Werner Koch <wk@g10code.com>
* w32-pth.c (do_pth_event_free): The events are hold in a ring
diff --git a/jnlib/logging.c b/jnlib/logging.c
index 781f03e6d..97a2b9c9e 100644
--- a/jnlib/logging.c
+++ b/jnlib/logging.c
@@ -1,6 +1,6 @@
/* logging.c - useful logging functions
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
- * 2004 Free Software Foundation, Inc.
+ * 2004, 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -20,11 +20,6 @@
*/
-/* This file should replace logger.c in the future - for now it is not
- * used by GnuPG but by GPA.
- * It is a quite simple implemenation but sufficient for most purposes.
- */
-
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
@@ -64,23 +59,6 @@ static int force_prefixes;
static int missing_lf;
static int errorcount;
-#if 0
-static void
-write2stderr( const char *s )
-{
- write( 2, s, strlen(s) );
-}
-
-
-static void
-do_die(int rc, const char *text )
-{
- write2stderr("\nFatal error: ");
- write2stderr(text);
- write2stderr("\n");
- abort();
-}
-#endif
int
log_get_errorcount (int clear)
@@ -150,7 +128,8 @@ fun_writer (void *cookie_arg, const char *buffer, size_t size)
cookie->fd = socket (PF_LOCAL, SOCK_STREAM, 0);
if (cookie->fd == -1)
{
- if (!cookie->quiet && !running_detached)
+ if (!cookie->quiet && !running_detached
+ && isatty (fileno (stderr)))
fprintf (stderr, "failed to create socket for logging: %s\n",
strerror(errno));
}
@@ -168,7 +147,8 @@ fun_writer (void *cookie_arg, const char *buffer, size_t size)
if (connect (cookie->fd, (struct sockaddr *) &addr, addrlen) == -1)
{
- if (!cookie->quiet && !running_detached)
+ if (!cookie->quiet && !running_detached
+ && isatty (fileno (stderr)))
fprintf (stderr, "can't connect to `%s': %s\n",
cookie->name, strerror(errno));
close (cookie->fd);
@@ -180,12 +160,16 @@ fun_writer (void *cookie_arg, const char *buffer, size_t size)
{
if (!running_detached)
{
+ /* Due to all the problems with apps not running
+ detahced but beeing caled with stderr closed or
+ used for a different purposes, it does not make
+ sense to switch to stderr. We tehrefore disable it. */
if (!cookie->quiet)
{
- fputs ("switching logging to stderr\n", stderr);
+ /* fputs ("switching logging to stderr\n", stderr);*/
cookie->quiet = 1;
}
- cookie->fd = fileno (stderr);
+ cookie->fd = -1; /*fileno (stderr);*/
}
}
else /* Connection has been established. */
@@ -199,7 +183,8 @@ fun_writer (void *cookie_arg, const char *buffer, size_t size)
if (cookie->fd != -1 && !writen (cookie->fd, buffer, size))
return size; /* Okay. */
- if (!running_detached && cookie->fd != -1)
+ if (!running_detached && cookie->fd != -1
+ && isatty (fileno (stderr)))
{
if (*cookie->name)
fprintf (stderr, "error writing to `%s': %s\n",