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
fa309382
Commit
fa309382
authored
Feb 15, 2017
by
Hisham
Browse files
Merge branch 'master' of
https://github.com/hishamhm/htop
parents
bb8dec15
aa813c75
Changes
11
Hide whitespace changes
Inline
Side-by-side
CPUMeter.c
View file @
fa309382
...
...
@@ -48,7 +48,7 @@ static void CPUMeter_init(Meter* this) {
int
cpu
=
this
->
param
;
if
(
this
->
pl
->
cpuCount
>
1
)
{
char
caption
[
10
];
sprintf
(
caption
,
"%-3d"
,
Settings_cpuId
(
this
->
pl
->
settings
,
cpu
-
1
));
s
n
printf
(
caption
,
sizeof
(
caption
),
"%-3d"
,
Settings_cpuId
(
this
->
pl
->
settings
,
cpu
-
1
));
Meter_setCaption
(
this
,
caption
);
}
if
(
this
->
param
==
0
)
...
...
@@ -74,44 +74,44 @@ static void CPUMeter_display(Object* cast, RichString* out) {
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"absent"
);
return
;
}
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_NORMAL
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_NORMAL
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
":"
);
RichString_append
(
out
,
CRT_colors
[
CPU_NORMAL
],
buffer
);
if
(
this
->
pl
->
settings
->
detailedCPUTime
)
{
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_KERNEL
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_KERNEL
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"sy:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_KERNEL
],
buffer
);
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_NICE
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_NICE
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"ni:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_NICE_TEXT
],
buffer
);
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_IRQ
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_IRQ
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"hi:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_IRQ
],
buffer
);
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_SOFTIRQ
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_SOFTIRQ
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"si:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_SOFTIRQ
],
buffer
);
if
(
this
->
values
[
CPU_METER_STEAL
])
{
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_STEAL
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_STEAL
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"st:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_STEAL
],
buffer
);
}
if
(
this
->
values
[
CPU_METER_GUEST
])
{
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_GUEST
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_GUEST
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"gu:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_GUEST
],
buffer
);
}
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_IOWAIT
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_IOWAIT
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"wa:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_IOWAIT
],
buffer
);
}
else
{
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_KERNEL
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_KERNEL
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"sys:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_KERNEL
],
buffer
);
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_NICE
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_NICE
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"low:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_NICE_TEXT
],
buffer
);
if
(
this
->
values
[
CPU_METER_IRQ
])
{
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
CPU_METER_IRQ
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%5.1f%% "
,
this
->
values
[
CPU_METER_IRQ
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"vir:"
);
RichString_append
(
out
,
CRT_colors
[
CPU_GUEST
],
buffer
);
}
...
...
LoadAverageMeter.c
View file @
fa309382
...
...
@@ -28,11 +28,11 @@ static void LoadAverageMeter_updateValues(Meter* this, char* buffer, int size) {
static
void
LoadAverageMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
Meter
*
this
=
(
Meter
*
)
cast
;
char
buffer
[
20
];
sprintf
(
buffer
,
"%.2f "
,
this
->
values
[
0
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%.2f "
,
this
->
values
[
0
]);
RichString_write
(
out
,
CRT_colors
[
LOAD_AVERAGE_ONE
],
buffer
);
sprintf
(
buffer
,
"%.2f "
,
this
->
values
[
1
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%.2f "
,
this
->
values
[
1
]);
RichString_append
(
out
,
CRT_colors
[
LOAD_AVERAGE_FIVE
],
buffer
);
sprintf
(
buffer
,
"%.2f "
,
this
->
values
[
2
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%.2f "
,
this
->
values
[
2
]);
RichString_append
(
out
,
CRT_colors
[
LOAD_AVERAGE_FIFTEEN
],
buffer
);
}
...
...
@@ -48,7 +48,7 @@ static void LoadMeter_updateValues(Meter* this, char* buffer, int size) {
static
void
LoadMeter_display
(
Object
*
cast
,
RichString
*
out
)
{
Meter
*
this
=
(
Meter
*
)
cast
;
char
buffer
[
20
];
sprintf
(
buffer
,
"%.2f "
,
((
Meter
*
)
this
)
->
values
[
0
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%.2f "
,
((
Meter
*
)
this
)
->
values
[
0
]);
RichString_write
(
out
,
CRT_colors
[
LOAD
],
buffer
);
}
...
...
Process.c
View file @
fa309382
...
...
@@ -198,7 +198,7 @@ void Process_setupColumnWidths() {
snprintf
(
Process_titleBuffer
[
i
],
20
,
"%*s "
,
digits
,
Process_pidColumns
[
i
].
label
);
Process_fields
[
Process_pidColumns
[
i
].
id
].
title
=
Process_titleBuffer
[
i
];
}
sprintf
(
Process_pidFormat
,
"%%%dd "
,
digits
);
s
n
printf
(
Process_pidFormat
,
sizeof
(
Process_pidFormat
),
"%%%dd "
,
digits
);
}
void
Process_humanNumber
(
RichString
*
str
,
unsigned
long
number
,
bool
coloring
)
{
...
...
TasksMeter.c
View file @
fa309382
...
...
@@ -40,7 +40,7 @@ static void TasksMeter_display(Object* cast, RichString* out) {
int
processes
=
(
int
)
this
->
values
[
2
];
sprintf
(
buffer
,
"%d"
,
processes
);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
processes
);
RichString_write
(
out
,
CRT_colors
[
METER_VALUE
],
buffer
);
int
threadValueColor
=
CRT_colors
[
METER_VALUE
];
int
threadCaptionColor
=
CRT_colors
[
METER_TEXT
];
...
...
@@ -50,18 +50,18 @@ static void TasksMeter_display(Object* cast, RichString* out) {
}
if
(
!
settings
->
hideUserlandThreads
)
{
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
", "
);
sprintf
(
buffer
,
"%d"
,
(
int
)
this
->
values
[
1
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
(
int
)
this
->
values
[
1
]);
RichString_append
(
out
,
threadValueColor
,
buffer
);
RichString_append
(
out
,
threadCaptionColor
,
" thr"
);
}
if
(
!
settings
->
hideKernelThreads
)
{
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
", "
);
sprintf
(
buffer
,
"%d"
,
(
int
)
this
->
values
[
0
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
(
int
)
this
->
values
[
0
]);
RichString_append
(
out
,
threadValueColor
,
buffer
);
RichString_append
(
out
,
threadCaptionColor
,
" kthr"
);
}
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"; "
);
sprintf
(
buffer
,
"%d"
,
(
int
)
this
->
values
[
3
]);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
(
int
)
this
->
values
[
3
]);
RichString_append
(
out
,
CRT_colors
[
TASKS_RUNNING
],
buffer
);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
" running"
);
}
...
...
TraceScreen.c
View file @
fa309382
...
...
@@ -99,7 +99,7 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
dup2
(
this
->
fdpair
[
1
],
STDERR_FILENO
);
int
ok
=
fcntl
(
this
->
fdpair
[
1
],
F_SETFL
,
O_NONBLOCK
);
if
(
ok
!=
-
1
)
{
sprintf
(
buffer
,
"%d"
,
this
->
super
.
process
->
pid
);
s
n
printf
(
buffer
,
sizeof
(
buffer
),
"%d"
,
this
->
super
.
process
->
pid
);
execlp
(
"strace"
,
"strace"
,
"-p"
,
buffer
,
NULL
);
}
const
char
*
message
=
"Could not execute 'strace'. Please make sure it is available in your $PATH."
;
...
...
UptimeMeter.c
View file @
fa309382
...
...
@@ -33,11 +33,11 @@ static void UptimeMeter_updateValues(Meter* this, char* buffer, int len) {
}
char
daysbuf
[
15
];
if
(
days
>
100
)
{
sprintf
(
daysbuf
,
"%d days(!), "
,
days
);
s
n
printf
(
daysbuf
,
sizeof
(
daysbuf
),
"%d days(!), "
,
days
);
}
else
if
(
days
>
1
)
{
sprintf
(
daysbuf
,
"%d days, "
,
days
);
s
n
printf
(
daysbuf
,
sizeof
(
daysbuf
),
"%d days, "
,
days
);
}
else
if
(
days
==
1
)
{
sprintf
(
daysbuf
,
"1 day, "
);
s
n
printf
(
daysbuf
,
sizeof
(
daysbuf
),
"1 day, "
);
}
else
{
daysbuf
[
0
]
=
'\0'
;
}
...
...
darwin/Platform.c
View file @
fa309382
...
...
@@ -78,7 +78,7 @@ ProcessFieldData Process_fields[] = {
[
STATE
]
=
{
.
name
=
"STATE"
,
.
title
=
"S "
,
.
description
=
"Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)"
,
.
flags
=
0
,
},
[
PPID
]
=
{
.
name
=
"PPID"
,
.
title
=
" PPID "
,
.
description
=
"Parent process ID"
,
.
flags
=
0
,
},
[
PGRP
]
=
{
.
name
=
"PGRP"
,
.
title
=
" PGRP "
,
.
description
=
"Process group ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SESN
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SID
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
TTY_NR
]
=
{
.
name
=
"TTY_NR"
,
.
title
=
" TTY "
,
.
description
=
"Controlling terminal"
,
.
flags
=
0
,
},
[
TPGID
]
=
{
.
name
=
"TPGID"
,
.
title
=
" TPGID "
,
.
description
=
"Process ID of the fg process group of the controlling terminal"
,
.
flags
=
0
,
},
[
MINFLT
]
=
{
.
name
=
"MINFLT"
,
.
title
=
" MINFLT "
,
.
description
=
"Number of minor faults which have not required loading a memory page from disk"
,
.
flags
=
0
,
},
...
...
@@ -166,7 +166,7 @@ ProcessPidColumn Process_pidColumns[] = {
{
.
id
=
TPGID
,
.
label
=
"TPGID"
},
{
.
id
=
TGID
,
.
label
=
"TGID"
},
{
.
id
=
PGRP
,
.
label
=
"PGRP"
},
{
.
id
=
SESSION
,
.
label
=
"S
ESN
"
},
{
.
id
=
SESSION
,
.
label
=
"S
ID
"
},
{
.
id
=
0
,
.
label
=
NULL
},
};
...
...
freebsd/FreeBSDProcess.c
View file @
fa309382
...
...
@@ -61,7 +61,7 @@ ProcessFieldData Process_fields[] = {
[
STATE
]
=
{
.
name
=
"STATE"
,
.
title
=
"S "
,
.
description
=
"Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)"
,
.
flags
=
0
,
},
[
PPID
]
=
{
.
name
=
"PPID"
,
.
title
=
" PPID "
,
.
description
=
"Parent process ID"
,
.
flags
=
0
,
},
[
PGRP
]
=
{
.
name
=
"PGRP"
,
.
title
=
" PGRP "
,
.
description
=
"Process group ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SESN
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SID
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
TTY_NR
]
=
{
.
name
=
"TTY_NR"
,
.
title
=
" TTY "
,
.
description
=
"Controlling terminal"
,
.
flags
=
0
,
},
[
TPGID
]
=
{
.
name
=
"TPGID"
,
.
title
=
" TPGID "
,
.
description
=
"Process ID of the fg process group of the controlling terminal"
,
.
flags
=
0
,
},
[
MINFLT
]
=
{
.
name
=
"MINFLT"
,
.
title
=
" MINFLT "
,
.
description
=
"Number of minor faults which have not required loading a memory page from disk"
,
.
flags
=
0
,
},
...
...
@@ -92,7 +92,7 @@ ProcessPidColumn Process_pidColumns[] = {
{
.
id
=
TPGID
,
.
label
=
"TPGID"
},
{
.
id
=
TGID
,
.
label
=
"TGID"
},
{
.
id
=
PGRP
,
.
label
=
"PGRP"
},
{
.
id
=
SESSION
,
.
label
=
"S
ESN
"
},
{
.
id
=
SESSION
,
.
label
=
"S
ID
"
},
{
.
id
=
0
,
.
label
=
NULL
},
};
...
...
htop.1.in
View file @
fa309382
...
...
@@ -217,7 +217,7 @@ The parent process ID.
.B PGRP
The process's group ID.
.TP
.B SESSION (S
ESN
)
.B SESSION (S
ID
)
The process's session ID.
.TP
.B TTY_NR (TTY)
...
...
linux/LinuxProcess.c
View file @
fa309382
...
...
@@ -144,7 +144,7 @@ ProcessFieldData Process_fields[] = {
[
STATE
]
=
{
.
name
=
"STATE"
,
.
title
=
"S "
,
.
description
=
"Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)"
,
.
flags
=
0
,
},
[
PPID
]
=
{
.
name
=
"PPID"
,
.
title
=
" PPID "
,
.
description
=
"Parent process ID"
,
.
flags
=
0
,
},
[
PGRP
]
=
{
.
name
=
"PGRP"
,
.
title
=
" PGRP "
,
.
description
=
"Process group ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SESN
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SID
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
TTY_NR
]
=
{
.
name
=
"TTY_NR"
,
.
title
=
"TTY "
,
.
description
=
"Controlling terminal"
,
.
flags
=
0
,
},
[
TPGID
]
=
{
.
name
=
"TPGID"
,
.
title
=
" TPGID "
,
.
description
=
"Process ID of the fg process group of the controlling terminal"
,
.
flags
=
0
,
},
[
FLAGS
]
=
{
.
name
=
"FLAGS"
,
.
title
=
NULL
,
.
description
=
NULL
,
.
flags
=
0
,
},
...
...
@@ -227,7 +227,7 @@ ProcessPidColumn Process_pidColumns[] = {
{
.
id
=
TPGID
,
.
label
=
"TPGID"
},
{
.
id
=
TGID
,
.
label
=
"TGID"
},
{
.
id
=
PGRP
,
.
label
=
"PGRP"
},
{
.
id
=
SESSION
,
.
label
=
"S
ESN
"
},
{
.
id
=
SESSION
,
.
label
=
"S
ID
"
},
{
.
id
=
OOM
,
.
label
=
"OOM"
},
{
.
id
=
0
,
.
label
=
NULL
},
};
...
...
unsupported/Platform.c
View file @
fa309382
...
...
@@ -38,7 +38,7 @@ ProcessFieldData Process_fields[] = {
[
STATE
]
=
{
.
name
=
"STATE"
,
.
title
=
"S "
,
.
description
=
"Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging)"
,
.
flags
=
0
,
},
[
PPID
]
=
{
.
name
=
"PPID"
,
.
title
=
" PPID "
,
.
description
=
"Parent process ID"
,
.
flags
=
0
,
},
[
PGRP
]
=
{
.
name
=
"PGRP"
,
.
title
=
" PGRP "
,
.
description
=
"Process group ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SESN
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
SESSION
]
=
{
.
name
=
"SESSION"
,
.
title
=
"
SID
"
,
.
description
=
"Process's session ID"
,
.
flags
=
0
,
},
[
TTY_NR
]
=
{
.
name
=
"TTY_NR"
,
.
title
=
" TTY "
,
.
description
=
"Controlling terminal"
,
.
flags
=
0
,
},
[
TPGID
]
=
{
.
name
=
"TPGID"
,
.
title
=
" TPGID "
,
.
description
=
"Process ID of the fg process group of the controlling terminal"
,
.
flags
=
0
,
},
[
MINFLT
]
=
{
.
name
=
"MINFLT"
,
.
title
=
" MINFLT "
,
.
description
=
"Number of minor faults which have not required loading a memory page from disk"
,
.
flags
=
0
,
},
...
...
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