summaryrefslogtreecommitdiffstats
path: root/src/basic/process-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-18 16:08:51 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-18 16:23:45 +0200
commit7e7a16a00e6702b04d424371a6a8b76050791f05 (patch)
treef43c5ccb21f782cf4b2934bb8350e89f027da8ac /src/basic/process-util.c
parentmount-util: FOREACH_LINE() excorcism (diff)
downloadsystemd-7e7a16a00e6702b04d424371a6a8b76050791f05.tar.xz
systemd-7e7a16a00e6702b04d424371a6a8b76050791f05.zip
process-util: FOREACH_LINE excorcism
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r--src/basic/process-util.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c
index a02ceb79e5..b2aab853e2 100644
--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -25,6 +25,7 @@
#include "alloc-util.h"
#include "architecture.h"
+#include "def.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
@@ -514,8 +515,8 @@ int get_process_exe(pid_t pid, char **name) {
static int get_process_id(pid_t pid, const char *field, uid_t *uid) {
_cleanup_fclose_ FILE *f = NULL;
- char line[LINE_MAX];
const char *p;
+ int r;
assert(field);
assert(uid);
@@ -533,9 +534,16 @@ static int get_process_id(pid_t pid, const char *field, uid_t *uid) {
(void) __fsetlocking(f, FSETLOCKING_BYCALLER);
- FOREACH_LINE(line, f, return -errno) {
+ for (;;) {
+ _cleanup_free_ char *line = NULL;
char *l;
+ r = read_line(f, LONG_LINE_MAX, &line);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ break;
+
l = strstrip(line);
if (startswith(l, field)) {