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
1 changed files with 9 additions and 4 deletions

View File

@ -1292,11 +1292,16 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_
} }
// filename is a number: process directory // filename is a number: process directory
int pid = atoi(name); int pid;
{
if (pid <= 0) char* endptr;
unsigned long parsedPid = strtoul(name, &endptr, 10);
if (parsedPid == 0 || parsedPid == ULONG_MAX || *endptr != '\0')
continue; continue;
pid = parsedPid;
}
// Skip task directory of main thread
if (parent && pid == parent->pid) if (parent && pid == parent->pid)
continue; continue;