[PATCH 04/10] Append to the log file instead of truncating it

Julien Cristau jcristau at debian.org
Tue Jan 5 10:18:18 PST 2010


Based on patch by Branden Robinson <branden at debian.org>
---
 error.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/error.c b/error.c
index 4f5eb6b..f86a250 100644
--- a/error.c
+++ b/error.c
@@ -38,6 +38,7 @@ from The Open Group.
 
 #include <stdio.h>
 #include <stdarg.h>
+#include <errno.h>
 
 #include "dm.h"
 #include "dm_error.h"
@@ -140,13 +141,13 @@ InitErrorLog (void)
 {
     int	i;
     if (errorLogFile[0]) {
-	i = creat (errorLogFile, 0666);
+	i = open (errorLogFile, O_WRONLY|O_CREAT|O_APPEND, 0666);
 	if (i != -1) {
 	    if (i != STDERR_FILENO) {
 		dup2 (i, STDERR_FILENO);
 		close (i);
 	    }
 	} else
-	    LogError ("Cannot open errorLogFile %s\n", errorLogFile);
+	    LogError ("Cannot open errorLogFile %s: %s\n", errorLogFile, _SysErrorMsg (errno));
     }
 }
-- 
1.6.5.7



More information about the xorg-devel mailing list