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
2ed83d69
Commit
2ed83d69
authored
Aug 12, 2015
by
Hisham Muhammad
Browse files
Merge branch 'master' of
https://github.com/hishamhm/htop
parents
041fa9ff
c34b5740
Changes
16
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
2ed83d69
...
@@ -9,6 +9,7 @@ htop
...
@@ -9,6 +9,7 @@ htop
*.gcno
*.gcno
*/*.gcno
*/*.gcno
*.h.gch
*.h.gch
*/.dirstamp
.deps/
.deps/
Makefile
Makefile
...
...
CRT.c
View file @
2ed83d69
...
@@ -16,6 +16,7 @@ in the source distribution for its full text.
...
@@ -16,6 +16,7 @@ in the source distribution for its full text.
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <locale.h>
#include <locale.h>
#include <langinfo.h>
#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j)
#define ColorPair(i,j) COLOR_PAIR((7-i)*8+j)
...
@@ -180,7 +181,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
...
@@ -180,7 +181,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Black
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Black
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_THREAD
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_THREAD
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Green
,
Black
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Green
,
Black
),
[
BAR_BORDER
]
=
A_BOLD
,
[
BAR_BORDER
]
=
A_BOLD
,
...
@@ -298,7 +299,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
...
@@ -298,7 +299,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
White
),
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
White
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
White
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
White
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
White
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
White
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Red
,
White
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Green
,
White
),
[
PROCESS_THREAD
]
=
ColorPair
(
Blue
,
White
),
[
PROCESS_THREAD
]
=
ColorPair
(
Blue
,
White
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Blue
,
White
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Blue
,
White
),
[
BAR_BORDER
]
=
ColorPair
(
Blue
,
White
),
[
BAR_BORDER
]
=
ColorPair
(
Blue
,
White
),
...
@@ -357,7 +358,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
...
@@ -357,7 +358,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Black
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Black
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_THREAD
]
=
ColorPair
(
Blue
,
Black
),
[
PROCESS_THREAD
]
=
ColorPair
(
Blue
,
Black
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Blue
,
Black
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Blue
,
Black
),
[
BAR_BORDER
]
=
ColorPair
(
Blue
,
Black
),
[
BAR_BORDER
]
=
ColorPair
(
Blue
,
Black
),
...
@@ -416,7 +417,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
...
@@ -416,7 +417,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Blue
),
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Blue
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Blue
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Blue
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Blue
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Blue
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Red
,
Blue
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Green
,
Blue
),
[
PROCESS_THREAD
]
=
ColorPair
(
Green
,
Blue
),
[
PROCESS_THREAD
]
=
ColorPair
(
Green
,
Blue
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Green
,
Blue
),
[
PROCESS_THREAD_BASENAME
]
=
A_BOLD
|
ColorPair
(
Green
,
Blue
),
[
BAR_BORDER
]
=
A_BOLD
|
ColorPair
(
Yellow
,
Blue
),
[
BAR_BORDER
]
=
A_BOLD
|
ColorPair
(
Yellow
,
Blue
),
...
@@ -477,7 +478,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
...
@@ -477,7 +478,7 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_R_STATE
]
=
ColorPair
(
Green
,
Black
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Black
),
[
PROCESS_D_STATE
]
=
A_BOLD
|
ColorPair
(
Red
,
Black
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_HIGH_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Red
,
Black
),
[
PROCESS_LOW_PRIORITY
]
=
ColorPair
(
Green
,
Black
),
[
BAR_BORDER
]
=
A_BOLD
|
ColorPair
(
Green
,
Black
),
[
BAR_BORDER
]
=
A_BOLD
|
ColorPair
(
Green
,
Black
),
[
BAR_SHADOW
]
=
ColorPair
(
Cyan
,
Black
),
[
BAR_SHADOW
]
=
ColorPair
(
Cyan
,
Black
),
[
SWAP
]
=
ColorPair
(
Red
,
Black
),
[
SWAP
]
=
ColorPair
(
Red
,
Black
),
...
@@ -585,15 +586,11 @@ void CRT_init(int delay, int colorScheme) {
...
@@ -585,15 +586,11 @@ void CRT_init(int delay, int colorScheme) {
CRT_colorScheme
=
1
;
CRT_colorScheme
=
1
;
CRT_setColors
(
CRT_colorScheme
);
CRT_setColors
(
CRT_colorScheme
);
/* initialize locale */
setlocale
(
LC_CTYPE
,
""
);
#ifdef HAVE_LIBNCURSESW
#ifdef HAVE_LIBNCURSESW
char
*
locale
=
setlocale
(
LC_ALL
,
NULL
);
if
(
strcmp
(
nl_langinfo
(
CODESET
),
"UTF-8"
)
==
0
)
if
(
locale
==
NULL
||
locale
[
0
]
==
'\0'
)
locale
=
setlocale
(
LC_CTYPE
,
NULL
);
if
(
locale
!=
NULL
&&
(
strstr
(
locale
,
"UTF-8"
)
||
strstr
(
locale
,
"utf-8"
)
||
strstr
(
locale
,
"UTF8"
)
||
strstr
(
locale
,
"utf8"
)))
CRT_utf8
=
true
;
CRT_utf8
=
true
;
else
else
CRT_utf8
=
false
;
CRT_utf8
=
false
;
...
...
Header.c
View file @
2ed83d69
...
@@ -85,6 +85,7 @@ void Header_writeBackToSettings(const Header* this) {
...
@@ -85,6 +85,7 @@ void Header_writeBackToSettings(const Header* this) {
colSettings
->
names
=
calloc
(
len
+
1
,
sizeof
(
char
*
));
colSettings
->
names
=
calloc
(
len
+
1
,
sizeof
(
char
*
));
colSettings
->
modes
=
calloc
(
len
,
sizeof
(
int
));
colSettings
->
modes
=
calloc
(
len
,
sizeof
(
int
));
colSettings
->
len
=
len
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
Meter
*
meter
=
(
Meter
*
)
Vector_get
(
vec
,
i
);
Meter
*
meter
=
(
Meter
*
)
Vector_get
(
vec
,
i
);
...
...
MemoryMeter.c
View file @
2ed83d69
...
@@ -26,7 +26,7 @@ int MemoryMeter_attributes[] = {
...
@@ -26,7 +26,7 @@ int MemoryMeter_attributes[] = {
static
void
MemoryMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
static
void
MemoryMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
Platform_setMemoryValues
(
this
);
Platform_setMemoryValues
(
this
);
snprintf
(
buffer
,
size
,
"%ld/%ldM
B
"
,
(
long
int
)
this
->
values
[
0
]
/
1024
,
(
long
int
)
this
->
total
/
1024
);
snprintf
(
buffer
,
size
,
"%ld/%ldM"
,
(
long
int
)
this
->
values
[
0
]
/
1024
,
(
long
int
)
this
->
total
/
1024
);
}
}
static
void
MemoryMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
static
void
MemoryMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
...
...
MetersPanel.c
View file @
2ed83d69
...
@@ -76,6 +76,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
...
@@ -76,6 +76,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
case
0x0d
:
case
0x0d
:
case
KEY_ENTER
:
case
KEY_ENTER
:
{
{
if
(
!
Vector_size
(
this
->
meters
))
break
;
this
->
moving
=
!
(
this
->
moving
);
this
->
moving
=
!
(
this
->
moving
);
((
ListItem
*
)
Panel_getSelected
(
super
))
->
moving
=
this
->
moving
;
((
ListItem
*
)
Panel_getSelected
(
super
))
->
moving
=
this
->
moving
;
result
=
HANDLED
;
result
=
HANDLED
;
...
@@ -85,6 +87,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
...
@@ -85,6 +87,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
case
KEY_F
(
4
):
case
KEY_F
(
4
):
case
't'
:
case
't'
:
{
{
if
(
!
Vector_size
(
this
->
meters
))
break
;
Meter
*
meter
=
(
Meter
*
)
Vector_get
(
this
->
meters
,
selected
);
Meter
*
meter
=
(
Meter
*
)
Vector_get
(
this
->
meters
,
selected
);
int
mode
=
meter
->
mode
+
1
;
int
mode
=
meter
->
mode
+
1
;
if
(
mode
==
LAST_METERMODE
)
mode
=
1
;
if
(
mode
==
LAST_METERMODE
)
mode
=
1
;
...
@@ -147,6 +151,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
...
@@ -147,6 +151,8 @@ static HandlerResult MetersPanel_eventHandler(Panel* super, int ch) {
case
KEY_F
(
9
):
case
KEY_F
(
9
):
case
KEY_DC
:
case
KEY_DC
:
{
{
if
(
!
Vector_size
(
this
->
meters
))
break
;
if
(
selected
<
Vector_size
(
this
->
meters
))
{
if
(
selected
<
Vector_size
(
this
->
meters
))
{
Vector_remove
(
this
->
meters
,
selected
);
Vector_remove
(
this
->
meters
,
selected
);
Panel_remove
(
super
,
selected
);
Panel_remove
(
super
,
selected
);
...
...
Process.c
View file @
2ed83d69
...
@@ -27,6 +27,11 @@ in the source distribution for its full text.
...
@@ -27,6 +27,11 @@ in the source distribution for its full text.
#include <time.h>
#include <time.h>
#include <assert.h>
#include <assert.h>
#ifdef __ANDROID__
#define SYS_ioprio_get __NR_ioprio_get
#define SYS_ioprio_set __NR_ioprio_set
#endif
// On Linux, this works only with glibc 2.1+. On earlier versions
// On Linux, this works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size.
// the behavior is similar to have a hardcoded page size.
#ifndef PAGE_SIZE
#ifndef PAGE_SIZE
...
...
Process.h
View file @
2ed83d69
...
@@ -9,6 +9,11 @@ Released under the GNU GPL, see the COPYING file
...
@@ -9,6 +9,11 @@ Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
in the source distribution for its full text.
*/
*/
#ifdef __ANDROID__
#define SYS_ioprio_get __NR_ioprio_get
#define SYS_ioprio_set __NR_ioprio_set
#endif
// On Linux, this works only with glibc 2.1+. On earlier versions
// On Linux, this works only with glibc 2.1+. On earlier versions
// the behavior is similar to have a hardcoded page size.
// the behavior is similar to have a hardcoded page size.
#ifndef PAGE_SIZE
#ifndef PAGE_SIZE
...
...
SwapMeter.c
View file @
2ed83d69
...
@@ -35,7 +35,7 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) {
...
@@ -35,7 +35,7 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) {
static
void
SwapMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
static
void
SwapMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
Platform_setSwapValues
(
this
);
Platform_setSwapValues
(
this
);
snprintf
(
buffer
,
len
,
"%ld/%ldM
B
"
,
(
long
int
)
this
->
values
[
0
]
/
MEGABYTE
,
(
long
int
)
this
->
total
/
MEGABYTE
);
snprintf
(
buffer
,
len
,
"%ld/%ldM"
,
(
long
int
)
this
->
values
[
0
]
/
MEGABYTE
,
(
long
int
)
this
->
total
/
MEGABYTE
);
}
}
static
void
SwapMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
static
void
SwapMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
...
...
TraceScreen.c
View file @
2ed83d69
...
@@ -93,7 +93,8 @@ void TraceScreen_run(TraceScreen* this) {
...
@@ -93,7 +93,8 @@ void TraceScreen_run(TraceScreen* this) {
execlp
(
"strace"
,
"strace"
,
"-p"
,
buffer
,
NULL
);
execlp
(
"strace"
,
"strace"
,
"-p"
,
buffer
,
NULL
);
}
}
const
char
*
message
=
"Could not execute 'strace'. Please make sure it is available in your $PATH."
;
const
char
*
message
=
"Could not execute 'strace'. Please make sure it is available in your $PATH."
;
write
(
fdpair
[
1
],
message
,
strlen
(
message
));
ssize_t
written
=
write
(
fdpair
[
1
],
message
,
strlen
(
message
));
(
void
)
written
;
exit
(
1
);
exit
(
1
);
}
}
fcntl
(
fdpair
[
0
],
F_SETFL
,
O_NONBLOCK
);
fcntl
(
fdpair
[
0
],
F_SETFL
,
O_NONBLOCK
);
...
...
freebsd/FreeBSDProcess.h
View file @
2ed83d69
...
@@ -28,6 +28,8 @@ typedef struct FreeBSDProcess_ {
...
@@ -28,6 +28,8 @@ typedef struct FreeBSDProcess_ {
#endif
#endif
extern
ProcessClass
FreeBSDProcess_class
;
extern
ProcessFieldData
Process_fields
[];
extern
ProcessFieldData
Process_fields
[];
extern
char
*
Process_pidFormat
;
extern
char
*
Process_pidFormat
;
...
@@ -39,9 +41,9 @@ FreeBSDProcess* FreeBSDProcess_new(Settings* settings);
...
@@ -39,9 +41,9 @@ FreeBSDProcess* FreeBSDProcess_new(Settings* settings);
void
Process_delete
(
Object
*
cast
);
void
Process_delete
(
Object
*
cast
);
void
Process_writeField
(
Process
*
this
,
RichString
*
str
,
ProcessField
field
);
void
FreeBSD
Process_writeField
(
Process
*
this
,
RichString
*
str
,
ProcessField
field
);
long
Process_compare
(
const
void
*
v1
,
const
void
*
v2
);
long
FreeBSD
Process_compare
(
const
void
*
v1
,
const
void
*
v2
);
bool
Process_isThread
(
Process
*
this
);
bool
Process_isThread
(
Process
*
this
);
...
...
freebsd/FreeBSDProcessList.c
View file @
2ed83d69
...
@@ -146,7 +146,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -146,7 +146,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
struct
kinfo_proc
*
kproc
=
&
kprocs
[
i
];
struct
kinfo_proc
*
kproc
=
&
kprocs
[
i
];
bool
preExisting
=
false
;
bool
preExisting
=
false
;
Process
*
proc
=
ProcessList_getProcess
(
this
,
kproc
->
ki_pid
,
&
preExisting
,
(
Process_
n
ew
_fn
)
FreeBSDProcess_new
);
Process
*
proc
=
ProcessList_getProcess
(
this
,
kproc
->
ki_pid
,
&
preExisting
,
(
Process_
N
ew
)
FreeBSDProcess_new
);
FreeBSDProcess
*
fp
=
(
FreeBSDProcess
*
)
proc
;
FreeBSDProcess
*
fp
=
(
FreeBSDProcess
*
)
proc
;
proc
->
show
=
!
((
hideKernelThreads
&&
Process_isKernelThread
(
proc
))
||
(
hideUserlandThreads
&&
Process_isUserlandThread
(
proc
)));
proc
->
show
=
!
((
hideKernelThreads
&&
Process_isKernelThread
(
proc
))
||
(
hideUserlandThreads
&&
Process_isUserlandThread
(
proc
)));
...
...
htop.1.in
View file @
2ed83d69
...
@@ -353,6 +353,15 @@ You may override the location of the configuration file using the $HTOPRC
...
@@ -353,6 +353,15 @@ You may override the location of the configuration file using the $HTOPRC
environment variable (so you can have multiple configurations for different
environment variable (so you can have multiple configurations for different
machines that share the same home directory, for example).
machines that share the same home directory, for example).
.SH "MEMORY SIZES"
.LP
Memory sizes in htop are displayed as they are in tools from the GNU Coreutils
(when ran with the --human-readable option). This means that sizes are printed
in powers of 1024. (e.g., 1023M = 1072693248 Bytes)
.LP
The decision to use this convention was made in order to conserve screen space
and make memory size representations consistent throughout htop.
.SH "SEE ALSO"
.SH "SEE ALSO"
proc(5), top(1), free(1), ps(1), uptime(1)
proc(5), top(1), free(1), ps(1), uptime(1)
...
...
htop.c
View file @
2ed83d69
...
@@ -184,20 +184,6 @@ int main(int argc, char** argv) {
...
@@ -184,20 +184,6 @@ int main(int argc, char** argv) {
}
}
#endif
#endif
#ifdef HAVE_LIBNCURSESW
char
*
locale
=
setlocale
(
LC_ALL
,
NULL
);
if
(
locale
==
NULL
||
locale
[
0
]
==
'\0'
)
locale
=
setlocale
(
LC_CTYPE
,
NULL
);
if
(
locale
!=
NULL
&&
(
strstr
(
locale
,
"UTF-8"
)
||
strstr
(
locale
,
"utf-8"
)
||
strstr
(
locale
,
"UTF8"
)
||
strstr
(
locale
,
"utf8"
)))
CRT_utf8
=
true
;
else
CRT_utf8
=
false
;
#endif
Process_setupColumnWidths
();
Process_setupColumnWidths
();
UsersTable
*
ut
=
UsersTable_new
();
UsersTable
*
ut
=
UsersTable_new
();
...
...
linux/LinuxProcess.c
View file @
2ed83d69
...
@@ -390,7 +390,7 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
...
@@ -390,7 +390,7 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
case
UTIME
:
diff
=
p2
->
utime
-
p1
->
utime
;
goto
test_diff
;
case
UTIME
:
diff
=
p2
->
utime
-
p1
->
utime
;
goto
test_diff
;
case
CUTIME
:
diff
=
p2
->
cutime
-
p1
->
cutime
;
goto
test_diff
;
case
CUTIME
:
diff
=
p2
->
cutime
-
p1
->
cutime
;
goto
test_diff
;
case
STIME
:
diff
=
p2
->
stime
-
p1
->
stime
;
goto
test_diff
;
case
STIME
:
diff
=
p2
->
stime
-
p1
->
stime
;
goto
test_diff
;
case
CSTIME
:
diff
=
p2
->
cstime
-
p
2
->
cstime
;
goto
test_diff
;
case
CSTIME
:
diff
=
p2
->
cstime
-
p
1
->
cstime
;
goto
test_diff
;
#ifdef HAVE_TASKSTATS
#ifdef HAVE_TASKSTATS
case
RCHAR
:
diff
=
p2
->
io_rchar
-
p1
->
io_rchar
;
goto
test_diff
;
case
RCHAR
:
diff
=
p2
->
io_rchar
-
p1
->
io_rchar
;
goto
test_diff
;
case
WCHAR
:
diff
=
p2
->
io_wchar
-
p1
->
io_wchar
;
goto
test_diff
;
case
WCHAR
:
diff
=
p2
->
io_wchar
-
p1
->
io_wchar
;
goto
test_diff
;
...
...
linux/LinuxProcessList.c
View file @
2ed83d69
...
@@ -94,7 +94,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
...
@@ -94,7 +94,8 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
int
cpus
=
-
1
;
int
cpus
=
-
1
;
do
{
do
{
cpus
++
;
cpus
++
;
fgets
(
buffer
,
255
,
file
);
char
*
s
=
fgets
(
buffer
,
255
,
file
);
(
void
)
s
;
}
while
(
String_startsWith
(
buffer
,
"cpu"
));
}
while
(
String_startsWith
(
buffer
,
"cpu"
));
fclose
(
file
);
fclose
(
file
);
...
@@ -674,7 +675,7 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
...
@@ -674,7 +675,7 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
unsigned
long
long
int
ioWait
,
irq
,
softIrq
,
steal
,
guest
,
guestnice
;
unsigned
long
long
int
ioWait
,
irq
,
softIrq
,
steal
,
guest
,
guestnice
;
unsigned
long
long
int
systemalltime
,
idlealltime
,
totaltime
,
virtalltime
;
unsigned
long
long
int
systemalltime
,
idlealltime
,
totaltime
,
virtalltime
;
ioWait
=
irq
=
softIrq
=
steal
=
guest
=
guestnice
=
0
;
ioWait
=
irq
=
softIrq
=
steal
=
guest
=
guestnice
=
0
;
// Depend
end
ing on your kernel version,
// Depending on your kernel version,
// 5, 7, 8 or 9 of these fields will be set.
// 5, 7, 8 or 9 of these fields will be set.
// The rest will remain at zero.
// The rest will remain at zero.
char
*
ok
=
fgets
(
buffer
,
255
,
file
);
char
*
ok
=
fgets
(
buffer
,
255
,
file
);
...
...
linux/Platform.c
View file @
2ed83d69
...
@@ -110,7 +110,8 @@ int Platform_getMaxPid() {
...
@@ -110,7 +110,8 @@ int Platform_getMaxPid() {
FILE
*
file
=
fopen
(
PROCDIR
"/sys/kernel/pid_max"
,
"r"
);
FILE
*
file
=
fopen
(
PROCDIR
"/sys/kernel/pid_max"
,
"r"
);
if
(
!
file
)
return
-
1
;
if
(
!
file
)
return
-
1
;
int
maxPid
=
4194303
;
int
maxPid
=
4194303
;
(
void
)
fscanf
(
file
,
"%32d"
,
&
maxPid
);
int
match
=
fscanf
(
file
,
"%32d"
,
&
maxPid
);
(
void
)
match
;
fclose
(
file
);
fclose
(
file
);
return
maxPid
;
return
maxPid
;
}
}
...
...
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