chiark / gitweb /
process-util: debug log if PR_SET_NAME fails.
authorLennart Poettering <lennart@poettering.net>
Sun, 24 Dec 2017 17:50:17 +0000 (18:50 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:49:45 +0000 (07:49 +0200)
src/basic/process-util.c

index 5a00fca834ff1b05931702eb86c7963b5ad13596..cb92bab0f51aa347b0b158d94700936a8e608972 100644 (file)
@@ -305,8 +305,10 @@ int rename_process(const char name[]) {
 
         l = strlen(name);
 
-        /* First step, change the comm field. */
-        (void) prctl(PR_SET_NAME, name);
+        /* First step, change the comm field. The main thread's comm is identical to the process comm. This means we
+         * can use PR_SET_NAME, which sets the thread name for the calling thread. */
+        if (prctl(PR_SET_NAME, name) < 0)
+                log_debug_errno(errno, "PR_SET_NAME failed: %m");
         if (l > 15) /* Linux process names can be 15 chars at max */
                 truncated = true;