From e79f68d11dcf4f7470fe21c219009c81e6433cf9 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 29 Jun 2013 13:11:44 -0400 Subject: 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. --- src/shared/util.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/shared/util.c b/src/shared/util.c index 04811ff26b..ceee6f2c90 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) { -- cgit v1.2.3-54-g00ecf