crash-manager: Do not make temporary copy of crashed process maps 62/189862/5
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 3 Oct 2018 11:14:20 +0000 (13:14 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 3 Oct 2018 13:45:32 +0000 (15:45 +0200)
It was needed when crash-worker used (now removed) ptrace
-based crash-stack, which woken up crashed process, causing
/proc/<PID>/ entries to disappear.

Change-Id: Iec344e6c3b9d7d12979173dea530684573a0761d

src/crash-manager/crash-manager.c

index af57938..686a13e 100644 (file)
@@ -77,7 +77,6 @@
 #define MINICOREDUMPER_TIMEOUT  DEFAULT_COMMAND_TIMEOUT
 #define CRASH_STACK_TIMEOUT     DEFAULT_COMMAND_TIMEOUT
 #define ZIP_TIMEOUT             DEFAULT_COMMAND_TIMEOUT
-#define TEMP_MAPS_FILENAME   "maps.temp"
 
 enum {
        RET_EXCEED = 1,
@@ -703,35 +702,12 @@ static int dump_system_state(const struct crash_info *cinfo)
        return system_command_parallel(command);
 }
 
-static void copy_maps(const struct crash_info *cinfo)
-{
-       char maps_path[PATH_MAX];
-       char temp_maps_path[PATH_MAX];
-       snprintf(maps_path, sizeof(maps_path), "/proc/%d/maps",
-                        cinfo->pid_info);
-
-       snprintf(temp_maps_path, sizeof(temp_maps_path), "%s/%s",
-                        cinfo->temp_dir, TEMP_MAPS_FILENAME);
-
-       copy_file(maps_path, temp_maps_path);
-}
-
-static void remove_maps(const struct crash_info *cinfo)
-{
-       char temp_maps_path[PATH_MAX];
-
-       snprintf(temp_maps_path, sizeof(temp_maps_path), "%s/%s",
-                        cinfo->temp_dir, TEMP_MAPS_FILENAME);
-       if (unlink(temp_maps_path) < 0)
-               _E("Cannot remove %s: %m\n", temp_maps_path);
-}
-
 static void save_so_info(const struct crash_info *cinfo)
 {
        char maps_path[PATH_MAX];
        char so_info_path[PATH_MAX];
-       snprintf(maps_path, sizeof(maps_path), "%s/%s",
-                        cinfo->temp_dir, TEMP_MAPS_FILENAME);
+       snprintf(maps_path, sizeof(maps_path), "/proc/%d/maps",
+                cinfo->pid_info);
 
        snprintf(so_info_path, sizeof(so_info_path),
                         "%s/%s.%s", cinfo->pfx, cinfo->name, "so_info");
@@ -1278,8 +1254,10 @@ int main(int argc, char *argv[])
                /* Exec dump_systemstate */
                dump_state_pid = dump_system_state(&cinfo);
 
-               /* Copy maps file to temp dir */
-               copy_maps(&cinfo);
+               if (dump_state_pid < 0) {
+                       res = EXIT_FAILURE;
+                       goto exit;
+               }
        }
        /* Exec crash modules */
        if (execute_crash_modules(&cinfo) < 0) {
@@ -1290,7 +1268,6 @@ int main(int argc, char *argv[])
        if (report_type >= REP_TYPE_FULL) {
                /* Save shared objects info (file names, bulid IDs, rpm package names) */
                save_so_info(&cinfo);
-               remove_maps(&cinfo);
 
                /* Wait dump_system_state */
                wait_system_command(dump_state_pid);