Execute dump_systemstate in parallel 34/115634/2
authorSunmin Lee <sunm.lee@samsung.com>
Tue, 21 Feb 2017 01:07:11 +0000 (10:07 +0900)
committerSunmin Lee <sunm.lee@samsung.com>
Tue, 21 Feb 2017 04:20:12 +0000 (13:20 +0900)
Since rearrange the order of crash modules, coredump had made
too late. It has caused several issues such as missing coredump
when something happened during dump_systemstate.
Therefore, execute dump_systemstate in parallel.

In addition, to avoid confusing launch crash-popup right after
whole crash works are finished.

Change-Id: I73c10c7d60f04d218f313b760c0381d0b8d95de7
Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
src/crash-manager/crash-manager.c
src/shared/util.c
src/shared/util.h

index 36b423c..d09bc0f 100644 (file)
@@ -430,7 +430,7 @@ exit:
                g_variant_unref(parameters);
 }
 
-static void dump_system_state(void)
+static int dump_system_state(void)
 {
        int ret;
        char command[PATH_MAX];
@@ -440,9 +440,10 @@ static void dump_system_state(void)
                        crash_info.log_path);
        if (ret < 0) {
                _E("Failed to snprintf for dump_systemstate command");
-               return;
+               return -1;
        }
-       system_command(command);
+
+       return system_command_parallel(command);
 }
 
 static void execute_crash_modules(int argc, char *argv[], int debug)
@@ -767,6 +768,9 @@ static void move_dump_dir(void)
 
 int main(int argc, char *argv[])
 {
+       /* Execute dump_systemstate in parallel */
+       static int dump_state_pid;
+
        prctl(PR_SET_DUMPABLE, 0);
 
        /* Get Configuration */
@@ -785,21 +789,24 @@ int main(int argc, char *argv[])
        get_sysassert_cs();
 #endif
 
-       /* .dbugmode: launch crash-popup */
-       if (access(DEBUGMODE_FILE, F_OK) == 0)
-               launch_crash_popup();
-
        /* Exec dump_systemstate */
-       dump_system_state();
+       dump_state_pid = dump_system_state();
 
        /* Exec crash modules */
        execute_crash_modules(argc, argv, DEBUG);
 
+       /* Wait dump_system_state */
+       wait_system_command(dump_state_pid);
+
        /* Tar compression */
        if (allow_zip)
                compress();
        else
                move_dump_dir();
 
+       /* .dbugmode: launch crash-popup */
+       if (access(DEBUGMODE_FILE, F_OK) == 0)
+               launch_crash_popup();
+
        return 0;
 }
index 01445fd..e8daf88 100644 (file)
 #include "util.h"
 #include "log.h"
 
-int system_command(char *command)
+int system_command_parallel(char *command)
 {
-       int pid = 0,
-               status = 0;
+       int pid = 0;
        const char *environ[] = { NULL };
 
        if (command == NULL)
@@ -56,6 +55,17 @@ int system_command(char *command)
                execve("/bin/sh", argv, (char **)environ);
                exit(127);
        }
+
+       return pid;
+}
+
+int wait_system_command(int pid)
+{
+       int status = 0;
+
+       if (pid < 0)
+               return -1;
+
        do {
                if (waitpid(pid, &status, 0) == -1) {
                        if (errno != EINTR)
@@ -73,6 +83,15 @@ int system_command(char *command)
        return 0;
 }
 
+int system_command(char *command)
+{
+       int pid = 0;
+
+       pid = system_command_parallel(command);
+
+       return wait_system_command(pid);
+}
+
 int system_command_with_timeout(int timeout_seconds, char *command)
 {
        const char *environ[] = { NULL };
index 2efa108..85416fa 100644 (file)
@@ -27,6 +27,10 @@ int system_command(char *command);
 
 int system_command_with_timeout(int timeout_seconds, char *command);
 
+int system_command_parallel(char *command);
+
+int wait_system_command(int pid);
+
 int fprintf_fd(int fd, const char *fmt, ...);
 
 int write_fd(int fd, const void *buf, int len);