From 3fcff0d75fdb5030e91458b36d2ea6f6f86ccd98 Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Tue, 11 Aug 2020 21:00:54 +0000 Subject: [PATCH] Align open_fdinfo_dir with pidfds_to_pids The function `pidfds_to_pids` expected `-1` if `open_fdinfo_dir` failed but the latter returned `errno` which is hard to distinguish from a valid file handle. Correct that by making `open_fdinfo_dir` a wrapper around `open`. --- common/common-pidfds.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/common/common-pidfds.c b/common/common-pidfds.c index a01cab7..00929f7 100644 --- a/common/common-pidfds.c +++ b/common/common-pidfds.c @@ -196,12 +196,5 @@ int pidfds_to_pids(int *fds, pid_t *pids, int count) /* misc directory helpers */ int open_fdinfo_dir(void) { - int fd; - - fd = open("/proc/self/fdinfo", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY); - - if (fd == -1) - return errno; - - return fd; + return open("/proc/self/fdinfo", O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY); }