summaryrefslogtreecommitdiffstats
path: root/src/basic/process-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-10-16 18:01:00 +0200
committerLennart Poettering <lennart@poettering.net>2023-10-17 14:36:54 +0200
commit0ff6ff2b29dfb02a803515fb0160d9963d2389d5 (patch)
tree378b5d42024534e03b59fb67034e5f95d3e62e69 /src/basic/process-util.c
parentfileio: add read_stripped_line() as trivial read_line() + strstrip() combo (diff)
downloadsystemd-0ff6ff2b29dfb02a803515fb0160d9963d2389d5.tar.xz
systemd-0ff6ff2b29dfb02a803515fb0160d9963d2389d5.zip
tree-wide: port various parsers over to read_stripped_line()
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r--src/basic/process-util.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index ed096900ac..6e51528065 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -473,16 +473,14 @@ static int get_process_id(pid_t pid, const char *field, uid_t *ret) {
_cleanup_free_ char *line = NULL;
char *l;
- r = read_line(f, LONG_LINE_MAX, &line);
+ r = read_stripped_line(f, LONG_LINE_MAX, &line);
if (r < 0)
return r;
if (r == 0)
break;
- l = strstrip(line);
-
- if (startswith(l, field)) {
- l += strlen(field);
+ l = startswith(line, field);
+ if (l) {
l += strspn(l, WHITESPACE);
l[strcspn(l, WHITESPACE)] = 0;