diff options
-rw-r--r-- | Process.c | 6 | ||||
-rw-r--r-- | sysdeps/linux.c | 11 | ||||
-rw-r--r-- | sysdeps/solaris.c | 5 |
3 files changed, 17 insertions, 5 deletions
@@ -265,11 +265,7 @@ static char* Process_pidFormat = "%7u "; static char* Process_tpgidFormat = "%7u "; void Process_getMaxPid() { - FILE* file = fopen(PROCDIR "/sys/kernel/pid_max", "r"); - if (!file) return; - int maxPid = 4194303; - fscanf(file, "%32d", &maxPid); - fclose(file); + int maxPid = sysdep_max_pid(); if (maxPid > 99999) { Process_fieldTitles[PID] = " PID "; Process_fieldTitles[PPID] = " PPID "; diff --git a/sysdeps/linux.c b/sysdeps/linux.c index 0d4ef28..72d2f40 100644 --- a/sysdeps/linux.c +++ b/sysdeps/linux.c @@ -138,3 +138,14 @@ void sysdep_update_cpu_data(ProcessList *this) } fclose(file); } + +int sysdep_max_pid() +{ + int maxPid = 4194303; + FILE* file = fopen(PROCDIR "/sys/kernel/pid_max", "r"); + if (file) { + fscanf(file, "%32d", &maxPid); + fclose(file); + } + return maxPid; +} diff --git a/sysdeps/solaris.c b/sysdeps/solaris.c index 51040de..e6e9696 100644 --- a/sysdeps/solaris.c +++ b/sysdeps/solaris.c @@ -80,3 +80,8 @@ void sysdep_update_cpu_data(ProcessList *this) cpuData->totalTime = totaltime; } } + +int sysdep_max_pid() +{ + return sysconf(_SC_MAXPID); +} |