diff options
author | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2020-05-21 12:55:24 +0200 |
---|---|---|
committer | Mateusz Moscicki <m.moscicki2@partner.samsung.com> | 2020-05-22 15:09:10 +0200 |
commit | fe09050937ac62206f243555d439d6b044436e12 (patch) | |
tree | f6da86c130f1b70cced5c2c0f47f74a813cc7ba6 | |
parent | 15e5e3d2bb1fc231b66d2ac28b6e8043818ddf15 (diff) | |
download | crash-worker-fe09050937ac62206f243555d439d6b044436e12.tar.gz crash-worker-fe09050937ac62206f243555d439d6b044436e12.tar.bz2 crash-worker-fe09050937ac62206f243555d439d6b044436e12.zip |
Read the /proc/<PID>/comm earlier
Change-Id: Ied692bc4e770c9aa3b8f03f7a2515214bc40cb63
-rw-r--r-- | src/crash-manager/crash-manager.c | 16 | ||||
-rw-r--r-- | src/crash-manager/crash-manager.h | 1 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/crash-manager/crash-manager.c b/src/crash-manager/crash-manager.c index 42044be..6011369 100644 --- a/src/crash-manager/crash-manager.c +++ b/src/crash-manager/crash-manager.c @@ -299,6 +299,13 @@ static bool get_cmd_info(struct crash_info *cinfo) if (!cinfo->cmd_line) return false; + if (!read_proc_file(cinfo->tid_info, "comm", buf, sizeof(buf), filter_drop_trailing_whitespace)) + goto err; + + cinfo->comm = strdup(buf); + if (!cinfo->comm) + goto err; + if (!get_exe_path(cinfo->pid_info, buf, sizeof(buf))) goto err; @@ -311,6 +318,8 @@ static bool get_cmd_info(struct crash_info *cinfo) err: free(cinfo->cmd_line); cinfo->cmd_line = NULL; + free(cinfo->comm); + cinfo->comm = NULL; return false; } @@ -616,9 +625,6 @@ static void launch_dbus_notify(struct crash_info *cinfo) char pid_str[11], tid_str[11], sig_str[11]; char *prstatus_fd_str = NULL; - char tid_comm_str[KERNEL_DEFINED_TASK_COMM_LEN + 1] = { 0, }; - - (void)read_proc_file(cinfo->tid_info, "comm", tid_comm_str, sizeof(tid_comm_str), filter_drop_trailing_whitespace); if (asprintf(&prstatus_fd_str, "%d", cinfo->prstatus_fd) == -1) { _E("Unable to allocate memory: %m"); @@ -641,7 +647,7 @@ static void launch_dbus_notify(struct crash_info *cinfo) "--reportpath", cinfo->result_path, "--prstatus_fd", prstatus_fd_str, "--signal", sig_str, - "--tid-comm", tid_comm_str, + "--tid-comm", cinfo->comm, legacy_notification_str, NULL }; @@ -1208,6 +1214,7 @@ static void free_crash_info(struct crash_info *cinfo) { free(cinfo->cmd_line); free(cinfo->cmd_path); + free(cinfo->comm); free(cinfo->temp_dir); free(cinfo->result_path); free(cinfo->app_root_path); @@ -1233,6 +1240,7 @@ void crash_info_init(struct crash_info *cinfo) cinfo->executable_path = NULL; cinfo->cmd_line = NULL; cinfo->cmd_path = NULL; + cinfo->comm = NULL; cinfo->temp_dir = NULL; cinfo->app_root_path = NULL; cinfo->pfx = NULL; diff --git a/src/crash-manager/crash-manager.h b/src/crash-manager/crash-manager.h index 320ef41..bd4f85b 100644 --- a/src/crash-manager/crash-manager.h +++ b/src/crash-manager/crash-manager.h @@ -36,6 +36,7 @@ struct crash_info { int prstatus_fd; char *cmd_line; char *cmd_path; + char *comm; char *temp_dir; char *name; char *app_root_path; |