summaryrefslogtreecommitdiff
path: root/src/crash-stack
diff options
context:
space:
mode:
authorSunmin Lee <sunm.lee@samsung.com>2017-02-20 18:46:44 +0900
committerSunmin Lee <sunm.lee@samsung.com>2017-02-20 18:46:44 +0900
commitdc13e21c2ae2aa2a11ff447e3fbe28183f5a9d55 (patch)
tree438a6383035b201fc2a24ae498f747f523084385 /src/crash-stack
parentd1ed66f003dff1fec1eff954b4145089a7685a4d (diff)
downloadcrash-worker-dc13e21c2ae2aa2a11ff447e3fbe28183f5a9d55.tar.gz
crash-worker-dc13e21c2ae2aa2a11ff447e3fbe28183f5a9d55.tar.bz2
crash-worker-dc13e21c2ae2aa2a11ff447e3fbe28183f5a9d55.zip
crash-stack: Get executable name from cmdline
The executable name in crash-stack is different with sys-assert. In case of some applications, "exe" has indicated real path of app that makes it hard to know what the actual app name is. It's better to refer to "cmdline" instead. Change-Id: I4895dbce427d50cd20a593585f2640554a4268fc Signed-off-by: Sunmin Lee <sunm.lee@samsung.com>
Diffstat (limited to 'src/crash-stack')
-rw-r--r--src/crash-stack/crash-stack.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/crash-stack/crash-stack.c b/src/crash-stack/crash-stack.c
index ca33a54..01c4b7f 100644
--- a/src/crash-stack/crash-stack.c
+++ b/src/crash-stack/crash-stack.c
@@ -510,14 +510,22 @@ void callstack_destructor(Callstack *callstack)
*/
static void __crash_stack_print_exe(FILE* outputfile, pid_t pid)
{
+ int fd, ret;
char file_path[PATH_MAX];
- char link_path[PATH_MAX];
+ char cmd_path[PATH_MAX];
- snprintf(link_path, PATH_MAX, "/proc/%d/exe", pid);
- if (readlink(link_path, file_path, PATH_MAX) == -1) {
+ snprintf(cmd_path, PATH_MAX, "/proc/%d/cmdline", pid);
+ if ((fd = open(cmd_path, O_RDONLY)) < 0)
+ return;
+
+ if ((ret = read(fd, file_path, sizeof(file_path))) <= 0) {
+ close(fd);
return;
}
+ file_path[ret] = '\0';
+
fprintf(outputfile, "Executable File Path: %s\n", file_path);
+ close(fd);
}
/**