From: Zbigniew Jędrzejewski-Szmek Date: Sat, 29 Jun 2013 17:11:44 +0000 (-0400) Subject: journald: drop (deleted) from _EXE= fields X-Git-Tag: v205~15 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=e79f68d11dcf4f7470fe21c219009c81e6433cf9;p=elogind.git journald: drop (deleted) from _EXE= fields The kernel adds those when the file is deleted, but we don't really care if the file is still there or not. The downside is that if the filename ends in ' (deleted)', this part of the filename will be removed. Too bad. --- diff --git a/src/shared/util.c b/src/shared/util.c index 04811ff26..ceee6f2c9 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -729,6 +729,8 @@ int is_kernel_thread(pid_t pid) { int get_process_exe(pid_t pid, char **name) { const char *p; + char *d; + int r; assert(pid >= 0); assert(name); @@ -738,7 +740,15 @@ int get_process_exe(pid_t pid, char **name) { else p = procfs_file_alloca(pid, "exe"); - return readlink_malloc(p, name); + r = readlink_malloc(p, name); + if (r < 0) + return r; + + d = endswith(*name, " (deleted)"); + if (d) + *d = '\0'; + + return 0; } static int get_process_id(pid_t pid, const char *field, uid_t *uid) {