diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2013-07-09 02:36:32 +0400 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2013-07-10 22:20:11 +0400 |
commit | 213a5cab3c8459912fdf8cb7ec78e4444049b583 (patch) | |
tree | 6cbdfa14595b353cfccddc3a4bcd05be78cdec03 | |
parent | 15a0937e2eb17556ebdb2d902d51cf917f80454a (diff) | |
download | htop-213a5cab3c8459912fdf8cb7ec78e4444049b583.tar.gz |
sysdep_max_pid()
-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); +} |