about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2008-07-26 22:43:16 +0000
committerUlrich Drepper <drepper@redhat.com>2008-07-26 22:43:16 +0000
commit72112b0cb4b10d27e7729d12bb9f937e13975379 (patch)
tree53ccb5717c30348c7d36f7ddf677c96249e4fa26
parent7438a80dcbb3c6766fe0288935c545c6a0f98257 (diff)
downloadglibc-72112b0cb4b10d27e7729d12bb9f937e13975379.tar.gz
glibc-72112b0cb4b10d27e7729d12bb9f937e13975379.tar.xz
glibc-72112b0cb4b10d27e7729d12bb9f937e13975379.zip
* malloc/mtrace.c (mtrace): Use 'e' flag in fopen call. Drop
	F_SETFD use if we know fopen set the flag.
-rw-r--r--ChangeLog3
-rw-r--r--malloc/mtrace.c18
2 files changed, 13 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index c58664c14a..3c6b0787eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2008-07-26  Ulrich Drepper  <drepper@redhat.com>
 
+	* malloc/mtrace.c (mtrace): Use 'e' flag in fopen call.  Drop
+	F_SETFD use if we know fopen set the flag.
+
 	* login/utmp_file.c (setutent_file): Minor optimization in case
 	O_CLOEXEC is available.
 
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 1a9522b09d..fafa52e916 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -1,5 +1,5 @@
 /* More debugging hooks for `malloc'.
-   Copyright (C) 1991-1994,1996-2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1991-1994,1996-2004, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 		 Written April 2, 1991 by John Gilmore of Cygnus Support.
 		 Based on mcheck.c by Mike Haertel.
@@ -34,13 +34,13 @@
 
 #include <stdio-common/_itoa.h>
 
-#ifdef _LIBC
-# include <libc-internal.h>
+#include <libc-internal.h>
 
-# include <libio/iolibio.h>
-# define setvbuf(s, b, f, l) INTUSE(_IO_setvbuf) (s, b, f, l)
-# define fwrite(buf, size, count, fp) _IO_fwrite (buf, size, count, fp)
-#endif
+#include <libio/iolibio.h>
+#define setvbuf(s, b, f, l) INTUSE(_IO_setvbuf) (s, b, f, l)
+#define fwrite(buf, size, count, fp) _IO_fwrite (buf, size, count, fp)
+
+#include <kernel-features.h>
 
 #ifndef attribute_hidden
 # define attribute_hidden
@@ -315,9 +315,10 @@ mtrace ()
       if (mtb == NULL)
 	return;
 
-      mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "wc");
+      mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "wce");
       if (mallstream != NULL)
 	{
+#ifndef __ASSUME_O_CLOEXEC
 	  /* Make sure we close the file descriptor on exec.  */
 	  int flags = __fcntl (fileno (mallstream), F_GETFD, 0);
 	  if (flags >= 0)
@@ -325,6 +326,7 @@ mtrace ()
 	      flags |= FD_CLOEXEC;
 	      __fcntl (fileno (mallstream), F_SETFD, flags);
 	    }
+#endif
 	  /* Be sure it doesn't malloc its buffer!  */
 	  malloc_trace_buffer = mtb;
 	  setvbuf (mallstream, malloc_trace_buffer, _IOFBF, TRACE_BUFFER_SIZE);