*/
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);
}
/**