chiark / gitweb /
journald: drop (deleted) from _EXE= fields
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 29 Jun 2013 17:11:44 +0000 (13:11 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 3 Jul 2013 03:06:22 +0000 (23:06 -0400)
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

index 04811ff26b8a64f94d9629e9fc27d1102232a78a..ceee6f2c90f6a7eecb1372d22e03b85a72184970 100644 (file)
@@ -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) {