Linux: use more robust pid parsing

Also add comment to condition
This commit is contained in:
Christian Göttsche 2021-04-18 15:49:45 +02:00 committed by cgzones
parent ace5730f89
commit a05e78f531

View File

@ -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;