mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Linux: use more robust pid parsing
Also add comment to condition
This commit is contained in:
parent
ace5730f89
commit
a05e78f531
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user