diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-06-01 21:43:43 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-06-01 21:49:16 +0200 |
commit | 92f14395cd43bb7969d3c7edaa53100d2f3c31d2 (patch) | |
tree | 8906283e934cf7e38006ee5dc4a1aabf3ab43a4d /src/basic | |
parent | e225e5c3c63822c51756ea4eb3545522523dbc1f (diff) | |
download | systemd-92f14395cd43bb7969d3c7edaa53100d2f3c31d2.tar.gz |
missing: define kernel internal limit TASK_COMM_LEN in userspace too
We already use it at two places, and we are about to add one too.
Arbitrary literally hardcoded limits suck.
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/missing.h | 7 | ||||
-rw-r--r-- | src/basic/process-util.c | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/basic/missing.h b/src/basic/missing.h index e714078f31..dbdbd6f260 100644 --- a/src/basic/missing.h +++ b/src/basic/missing.h @@ -1407,4 +1407,11 @@ struct statx { #define AT_STATX_DONT_SYNC 0x4000 #endif +/* The maximum thread/process name length including trailing NUL byte. This mimics the kernel definition of the same + * name, which we need in userspace at various places but is not defined in userspace currently, neither under this + * name nor any other. */ +#ifndef TASK_COMM_LEN +#define TASK_COMM_LEN 16 +#endif + #include "missing_syscall.h" diff --git a/src/basic/process-util.c b/src/basic/process-util.c index a503aa50dc..058f077de0 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -296,7 +296,7 @@ int rename_process(const char name[]) { * 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 */ + if (l >= TASK_COMM_LEN) /* Linux process names can be 15 chars at max */ truncated = true; /* Second step, change glibc's ID of the process name. */ |