Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
da0956d1
Commit
da0956d1
authored
Nov 27, 2014
by
Hisham Muhammad
Browse files
Merge branch 'master' into freebsd
parents
6d92d7f7
03ca7da8
Changes
5
Show whitespace changes
Inline
Side-by-side
Process.c
View file @
da0956d1
...
...
@@ -11,6 +11,7 @@ in the source distribution for its full text.
#include "CRT.h"
#include "String.h"
#include "RichString.h"
#include "Platform.h"
#include <stdio.h>
#include <sys/time.h>
...
...
@@ -284,12 +285,9 @@ static int Process_getuid = -1;
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
);
void
Process_setupColumnWidths
()
{
int
maxPid
=
Platform_getMaxPid
();
if
(
maxPid
==
-
1
)
return
;
if
(
maxPid
>
99999
)
{
Process_fieldTitles
[
PID
]
=
" PID "
;
Process_fieldTitles
[
PPID
]
=
" PPID "
;
...
...
Process.h
View file @
da0956d1
...
...
@@ -179,7 +179,7 @@ extern const int Process_fieldFlags[];
extern
const
char
*
Process_fieldTitles
[];
void
Process_
g
et
MaxPid
();
void
Process_
s
et
upColumnWidths
();
#define ONE_K 1024L
#define ONE_M (ONE_K * ONE_K)
...
...
htop.c
View file @
da0956d1
...
...
@@ -656,11 +656,12 @@ int main(int argc, char** argv) {
}
}
#ifdef HAVE_PROC
if
(
access
(
PROCDIR
,
R_OK
)
!=
0
)
{
fprintf
(
stderr
,
"Error: could not read procfs (compiled to look in %s).
\n
"
,
PROCDIR
);
exit
(
1
);
}
#endif
#ifdef HAVE_LIBNCURSESW
char
*
locale
=
setlocale
(
LC_ALL
,
NULL
);
...
...
@@ -680,7 +681,7 @@ int main(int argc, char** argv) {
ProcessList
*
pl
=
ProcessList_new
(
ut
,
pidWhiteList
);
pl
->
userOnly
=
userOnly
;
pl
->
userId
=
userId
;
Process_
g
et
MaxPid
();
Process_
s
et
upColumnWidths
();
Header
*
header
=
Header_new
(
pl
);
Settings
*
settings
=
Settings_new
(
pl
,
header
,
pl
->
cpuCount
);
...
...
linux/Platform.c
View file @
da0956d1
...
...
@@ -93,3 +93,12 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
}
}
int
Platform_getMaxPid
()
{
FILE
*
file
=
fopen
(
PROCDIR
"/sys/kernel/pid_max"
,
"r"
);
if
(
!
file
)
return
-
1
;
int
maxPid
=
4194303
;
fscanf
(
file
,
"%32d"
,
&
maxPid
);
fclose
(
file
);
return
maxPid
;
}
unsupported/Platform.c
View file @
da0956d1
...
...
@@ -54,3 +54,7 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
*
five
=
0
;
*
fifteen
=
0
;
}
int
Platform_getMaxPid
()
{
return
-
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment