debugch: Fix DEBUGCH and open flag 65/25565/1
authorMunkyu Im <munkyu.im@samsung.com>
Wed, 30 Jul 2014 07:49:52 +0000 (16:49 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 7 Aug 2014 05:45:10 +0000 (14:45 +0900)
Add O_APPEND to support writing stdout, stderr logs.
Set global variable for checking initailize earlier.
So succeded to read DEBUGCH file now.

Change-Id: I9eaef10ce81e138b613223417985acf27533b7bc
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
tizen/src/util/new_debug_ch.c

index 4effe69..b871522 100644 (file)
@@ -225,6 +225,7 @@ static void debug_init(void)
         return;  /* already initialized */
     }
 
+    nb_debug_options = 0;
     if (0 == strlen(bin_path)) {
         g_strlcpy(debugchfile, "DEBUGCH", MAX_FILE_LEN);
     } else {
@@ -237,6 +238,7 @@ static void debug_init(void)
         debug = getenv("DEBUGCH");
     } else {
         if ((tmp = (char *)malloc(1024 + 1)) == NULL){
+            nb_debug_options = -1;
             fclose(fp);
             return;
         }
@@ -248,6 +250,7 @@ static void debug_init(void)
             if (tmp != NULL)
                 free(tmp);
 
+            nb_debug_options = -1;
             return;
         }
         const char* str = fgets(tmp, 1024, fp);
@@ -272,7 +275,7 @@ static void debug_init(void)
 
     // If "log_path" is not set, we use "stdout".
     if (log_path[0] != '\0') {
-        fd = qemu_open(log_path, O_RDWR | O_CREAT | O_TRUNC, 0666);
+        fd = qemu_open(log_path, O_RDWR | O_CREAT | O_TRUNC | O_APPEND, 0666);
         if (fd < 0) {
             fprintf(stderr, "Can't open logfile: %s\n", log_path);
             exit(1);