gjs r78 - trunk/util



Author: tko
Date: Mon Nov 10 14:12:51 2008
New Revision: 78
URL: http://svn.gnome.org/viewvc/gjs?rev=78&view=rev

Log:
try to avoid clobbering shared logfiles

	* util/log.c (gjs_debug): try to avoid clobbering shared
	logfiles by opening them for appending, and seeking to end
	before writes

Modified:
   trunk/util/log.c

Modified: trunk/util/log.c
==============================================================================
--- trunk/util/log.c	(original)
+++ trunk/util/log.c	Mon Nov 10 14:12:51 2008
@@ -139,7 +139,8 @@
                 free_me = NULL;
             }
 
-            logfp = fopen(log_file, "w");
+            /* avoid truncating in case we're using shared logfile */
+            logfp = fopen(log_file, "a");
             if (!logfp)
                 fprintf(stderr, "Failed to open log file `%s': %s\n",
                         log_file, g_strerror(errno));
@@ -258,6 +259,9 @@
         access(s2, F_OK);
         g_free(s2);
     } else {
+        /* seek to end to avoid truncating in case we're using shared logfile */
+        (void)fseek(logfp, 0, SEEK_END);
+
         if (print_timestamp) {
             static gdouble previous = 0.0;
             gdouble total = g_timer_elapsed(timer, NULL) * 1000.0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]