aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_util.c
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2011-03-25 12:45:24 -0500
committerPeter Seebach <peter.seebach@windriver.com>2011-03-25 12:49:37 -0500
commitd7f261ef9223e3ca461de4057dc73a418408e431 (patch)
tree25cc9aa26fd1c8a164a29bdb8cde7585be9846b2 /pseudo_util.c
parent7deabd4818afcf9c7444abf724ad9d2523ec8910 (diff)
downloadpseudo-d7f261ef9223e3ca461de4057dc73a418408e431.tar.gz
pseudo-d7f261ef9223e3ca461de4057dc73a418408e431.tar.bz2
pseudo-d7f261ef9223e3ca461de4057dc73a418408e431.zip
Try to force debug fd to 2. The intent is that this will keep malloc
debugger messages from going to the wrong place. No longer fclose(stderr) after grabbing log file, because stderr is likely still using fd 2.
Diffstat (limited to 'pseudo_util.c')
-rw-r--r--pseudo_util.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/pseudo_util.c b/pseudo_util.c
index d19bd0c..ada6060 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -1371,6 +1371,19 @@ pseudo_logfile(char *defname) {
if (fd == -1) {
pseudo_diag("help: can't open log file %s: %s\n", pseudo_path, strerror(errno));
} else {
+ /* try to force fd to 2. We do this because glibc's malloc
+ * debug unconditionally writes to fd 2, and we don't want
+ * a client process ending op on fd 2, or server debugging
+ * becomes a nightmare.
+ */
+ if (fd != 2) {
+ int newfd;
+ close(2);
+ newfd = dup2(fd, 2);
+ if (newfd != -1) {
+ fd = newfd;
+ }
+ }
pseudo_util_debug_fd = fd;
}
free(pseudo_path);