summaryrefslogtreecommitdiffstats
path: root/linux/LinuxProcessList.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-04-18 15:49:45 +0200
committercgzones <cgzones@googlemail.com>2021-04-21 20:58:28 +0200
commita05e78f5318325e7d2f01bf4b8a0f11b8cf71371 (patch)
tree4d401d1c8fa37b75e58f387faaac6a47fdf118c3 /linux/LinuxProcessList.c
parentace5730f89ed6c394154d7ffa4f8f4b4a11dae66 (diff)
Linux: use more robust pid parsing
Also add comment to condition
Diffstat (limited to 'linux/LinuxProcessList.c')
-rw-r--r--linux/LinuxProcessList.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index 4564f8e6..f5a35193 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -1292,11 +1292,16 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
}
// filename is a number: process directory
- int pid = atoi(name);
-
- if (pid <= 0)
- continue;
+ int pid;
+ {
+ char* endptr;
+ unsigned long parsedPid = strtoul(name, &endptr, 10);
+ if (parsedPid == 0 || parsedPid == ULONG_MAX || *endptr != '\0')
+ continue;
+ pid = parsedPid;
+ }
+ // Skip task directory of main thread
if (parent && pid == parent->pid)
continue;

© 2014-2024 Faster IT GmbH | imprint | privacy policy