Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumphijack dprintf to stderr. stop doing it if stder...
details: https://anonhg.NetBSD.org/src/rev/f4502d00dd86
branches: trunk
changeset: 760611:f4502d00dd86
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Jan 09 10:28:46 2011 +0000
description:
dprintf to stderr. stop doing it if stderr_fileno gets dup2()'d
diffstat:
lib/librumphijack/hijack.c | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diffs (52 lines):
diff -r 2d42a4c262df -r f4502d00dd86 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c Sun Jan 09 09:47:55 2011 +0000
+++ b/lib/librumphijack/hijack.c Sun Jan 09 10:28:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hijack.c,v 1.4 2011/01/08 21:30:24 pooka Exp $ */
+/* $NetBSD: hijack.c,v 1.5 2011/01/09 10:28:46 pooka Exp $ */
/*-
* Copyright (c) 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.4 2011/01/08 21:30:24 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.5 2011/01/09 10:28:46 pooka Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -159,16 +159,29 @@
err(1, "rumpclient init");
}
+static unsigned dup2mask;
+#define ISDUP2D(fd) (((fd+1) & dup2mask) == ((fd)+1))
+
//#define DEBUGJACK
#ifdef DEBUGJACK
-#define DPRINTF(x) printf x
+#define DPRINTF(x) mydprintf x
+static void
+mydprintf(const char *fmt, ...)
+{
+ va_list ap;
+
+ if (ISDUP2D(STDERR_FILENO))
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+}
+
#else
#define DPRINTF(x)
#endif
-static unsigned dup2mask;
-#define ISDUP2D(fd) (((fd+1) & dup2mask) == ((fd)+1))
-
/* XXX: need runtime selection. low for now due to FD_SETSIZE */
#define HIJACK_FDOFF 128
#define HIJACK_SELECT 128 /* XXX */
Home |
Main Index |
Thread Index |
Old Index