mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-15 05:24:36 +03:00
Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
e2ccc7b240 | |||
ef1e62d1fa | |||
453105e77a | |||
db80f202f2 | |||
98e43816a5 | |||
694addceb5 | |||
4623394456 | |||
4ad7aa6432 | |||
4b780a3499 | |||
b08cb7352e | |||
b886ecc479 | |||
63c55854e5 | |||
4f1bd232d8 | |||
84a69b1ea4 | |||
e77811e99b | |||
0a4a447d0d | |||
03af73bbc7 | |||
0cf3cfa3af | |||
797bcd0961 | |||
baec4bdcb0 | |||
a8a5e62760 | |||
f5ddb974a1 | |||
565101234a | |||
d4741d5410 | |||
9668cd11ed | |||
c23d4f12d1 | |||
34431dc7fd | |||
42c4459375 | |||
48254f92e4 | |||
5ee6715843 | |||
c18309466d | |||
fe0ad86e6d | |||
dc4f145629 | |||
d43e709364 | |||
0627a5f0e9 | |||
d10f4f615a | |||
e0c364b9cc | |||
fd216309d9 | |||
474d26cea8 | |||
471cd60635 | |||
f554f08fa9 | |||
d753996b96 | |||
b10278318b | |||
35657208d7 | |||
ae823c375a | |||
1b5025e6f5 | |||
c66ac09a66 | |||
0b70439316 | |||
e9b32eb62f | |||
3b9a4b1024 | |||
0e3cf6975f | |||
a618f477b2 | |||
cc4267cc5c | |||
d0d14da8d9 | |||
1bedac1ca2 | |||
011bf30d22 | |||
c56b1a8830 | |||
01edfcf4d4 | |||
d916f6e6f0 | |||
e46488463d | |||
8fa9da47de | |||
d408c74465 | |||
bb0333e45d | |||
b6f927bffa | |||
f1d1d6e0d6 |
11
Action.c
11
Action.c
@ -271,7 +271,7 @@ static Htop_Reaction actionQuit() {
|
|||||||
static Htop_Reaction actionSetAffinity(State* st) {
|
static Htop_Reaction actionSetAffinity(State* st) {
|
||||||
if (st->pl->cpuCount == 1)
|
if (st->pl->cpuCount == 1)
|
||||||
return HTOP_OK;
|
return HTOP_OK;
|
||||||
#if (HAVE_LIBHWLOC || HAVE_NATIVE_AFFINITY)
|
#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY)
|
||||||
Panel* panel = st->panel;
|
Panel* panel = st->panel;
|
||||||
|
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
@ -387,6 +387,7 @@ static struct { const char* key; const char* info; } helpLeft[] = {
|
|||||||
{ .key = " F3 /: ", .info = "incremental name search" },
|
{ .key = " F3 /: ", .info = "incremental name search" },
|
||||||
{ .key = " F4 \\: ",.info = "incremental name filtering" },
|
{ .key = " F4 \\: ",.info = "incremental name filtering" },
|
||||||
{ .key = " F5 t: ", .info = "tree view" },
|
{ .key = " F5 t: ", .info = "tree view" },
|
||||||
|
{ .key = " p: ", .info = "toggle program path" },
|
||||||
{ .key = " u: ", .info = "show processes of a single user" },
|
{ .key = " u: ", .info = "show processes of a single user" },
|
||||||
{ .key = " H: ", .info = "hide/show user process threads" },
|
{ .key = " H: ", .info = "hide/show user process threads" },
|
||||||
{ .key = " K: ", .info = "hide/show kernel threads" },
|
{ .key = " K: ", .info = "hide/show kernel threads" },
|
||||||
@ -405,11 +406,11 @@ static struct { const char* key; const char* info; } helpRight[] = {
|
|||||||
{ .key = " F9 k: ", .info = "kill process/tagged processes" },
|
{ .key = " F9 k: ", .info = "kill process/tagged processes" },
|
||||||
{ .key = " F7 ]: ", .info = "higher priority (root only)" },
|
{ .key = " F7 ]: ", .info = "higher priority (root only)" },
|
||||||
{ .key = " F8 [: ", .info = "lower priority (+ nice)" },
|
{ .key = " F8 [: ", .info = "lower priority (+ nice)" },
|
||||||
#if (HAVE_LIBHWLOC || HAVE_NATIVE_AFFINITY)
|
#if (HAVE_LIBHWLOC || HAVE_LINUX_AFFINITY)
|
||||||
{ .key = " a: ", .info = "set CPU affinity" },
|
{ .key = " a: ", .info = "set CPU affinity" },
|
||||||
#endif
|
#endif
|
||||||
{ .key = " e: ", .info = "show process environment" },
|
{ .key = " e: ", .info = "show process environment" },
|
||||||
{ .key = " i: ", .info = "set IO prority" },
|
{ .key = " i: ", .info = "set IO priority" },
|
||||||
{ .key = " l: ", .info = "list open files with lsof" },
|
{ .key = " l: ", .info = "list open files with lsof" },
|
||||||
{ .key = " s: ", .info = "trace syscalls with strace" },
|
{ .key = " s: ", .info = "trace syscalls with strace" },
|
||||||
{ .key = " ", .info = "" },
|
{ .key = " ", .info = "" },
|
||||||
@ -479,8 +480,8 @@ static Htop_Reaction actionHelp(State* st) {
|
|||||||
for (int i = 0; helpLeft[i].key; i++) { mvaddstr(9+i, 0, helpLeft[i].key); }
|
for (int i = 0; helpLeft[i].key; i++) { mvaddstr(9+i, 0, helpLeft[i].key); }
|
||||||
for (int i = 0; helpRight[i].key; i++) { mvaddstr(9+i, 40, helpRight[i].key); }
|
for (int i = 0; helpRight[i].key; i++) { mvaddstr(9+i, 40, helpRight[i].key); }
|
||||||
attrset(CRT_colors[PROCESS_THREAD]);
|
attrset(CRT_colors[PROCESS_THREAD]);
|
||||||
mvaddstr(15, 32, "threads");
|
mvaddstr(16, 32, "threads");
|
||||||
mvaddstr(16, 26, "threads");
|
mvaddstr(17, 26, "threads");
|
||||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||||
|
|
||||||
attrset(CRT_colors[HELP_BOLD]);
|
attrset(CRT_colors[HELP_BOLD]);
|
||||||
|
19
Affinity.c
19
Affinity.c
@ -10,8 +10,13 @@ in the source distribution for its full text.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBHWLOC
|
#ifdef HAVE_LIBHWLOC
|
||||||
#include <hwloc/linux.h>
|
#include <hwloc.h>
|
||||||
#elif HAVE_NATIVE_AFFINITY
|
#if __linux__
|
||||||
|
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_THREAD
|
||||||
|
#else
|
||||||
|
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_PROCESS
|
||||||
|
#endif
|
||||||
|
#elif HAVE_LINUX_AFFINITY
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -55,7 +60,7 @@ void Affinity_add(Affinity* this, int id) {
|
|||||||
|
|
||||||
Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
||||||
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
|
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
|
||||||
bool ok = (hwloc_linux_get_tid_cpubind(pl->topology, proc->pid, cpuset) == 0);
|
bool ok = (hwloc_get_proc_cpubind(pl->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
|
||||||
Affinity* affinity = NULL;
|
Affinity* affinity = NULL;
|
||||||
if (ok) {
|
if (ok) {
|
||||||
affinity = Affinity_new(pl);
|
affinity = Affinity_new(pl);
|
||||||
@ -76,15 +81,15 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
|||||||
|
|
||||||
bool Affinity_set(Process* proc, Affinity* this) {
|
bool Affinity_set(Process* proc, Affinity* this) {
|
||||||
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
|
hwloc_cpuset_t cpuset = hwloc_bitmap_alloc();
|
||||||
for (int i = 0; i < affinity->used; i++) {
|
for (int i = 0; i < this->used; i++) {
|
||||||
hwloc_bitmap_set(cpuset, affinity->cpus[i]);
|
hwloc_bitmap_set(cpuset, this->cpus[i]);
|
||||||
}
|
}
|
||||||
bool ok = (hwloc_linux_set_tid_cpubind(this->pl->topology, proc->pid, cpuset) == 0);
|
bool ok = (hwloc_set_proc_cpubind(this->pl->topology, proc->pid, cpuset, HTOP_HWLOC_CPUBIND_FLAG) == 0);
|
||||||
hwloc_bitmap_free(cpuset);
|
hwloc_bitmap_free(cpuset);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_NATIVE_AFFINITY
|
#elif HAVE_LINUX_AFFINITY
|
||||||
|
|
||||||
Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
Affinity* Affinity_get(Process* proc, ProcessList* pl) {
|
||||||
cpu_set_t cpuset;
|
cpu_set_t cpuset;
|
||||||
|
@ -10,7 +10,12 @@ in the source distribution for its full text.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_LIBHWLOC
|
#ifdef HAVE_LIBHWLOC
|
||||||
#elif HAVE_NATIVE_AFFINITY
|
#if __linux__
|
||||||
|
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_THREAD
|
||||||
|
#else
|
||||||
|
#define HTOP_HWLOC_CPUBIND_FLAG HWLOC_CPUBIND_PROCESS
|
||||||
|
#endif
|
||||||
|
#elif HAVE_LINUX_AFFINITY
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
@ -36,7 +41,7 @@ Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
|||||||
|
|
||||||
bool Affinity_set(Process* proc, Affinity* this);
|
bool Affinity_set(Process* proc, Affinity* this);
|
||||||
|
|
||||||
#elif HAVE_NATIVE_AFFINITY
|
#elif HAVE_LINUX_AFFINITY
|
||||||
|
|
||||||
Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
Affinity* Affinity_get(Process* proc, ProcessList* pl);
|
||||||
|
|
||||||
|
8
CRT.c
8
CRT.c
@ -125,6 +125,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn));
|
|||||||
|
|
||||||
void CRT_handleSIGSEGV(int sgn);
|
void CRT_handleSIGSEGV(int sgn);
|
||||||
|
|
||||||
|
#define KEY_ALT(x) KEY_F(60) + (x - 'A')
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
|
const char *CRT_treeStrAscii[TREE_STR_COUNT] = {
|
||||||
@ -587,6 +589,11 @@ void CRT_init(int delay, int colorScheme) {
|
|||||||
define_key("\033[13~", KEY_F(3));
|
define_key("\033[13~", KEY_F(3));
|
||||||
define_key("\033[14~", KEY_F(4));
|
define_key("\033[14~", KEY_F(4));
|
||||||
define_key("\033[17;2~", KEY_F(18));
|
define_key("\033[17;2~", KEY_F(18));
|
||||||
|
char sequence[3] = "\033a";
|
||||||
|
for (char c = 'a'; c <= 'z'; c++) {
|
||||||
|
sequence[1] = c;
|
||||||
|
define_key(sequence, KEY_ALT('A' + (c - 'a')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
signal(11, CRT_handleSIGSEGV);
|
signal(11, CRT_handleSIGSEGV);
|
||||||
@ -618,6 +625,7 @@ void CRT_init(int delay, int colorScheme) {
|
|||||||
#else
|
#else
|
||||||
mousemask(BUTTON1_RELEASED, NULL);
|
mousemask(BUTTON1_RELEASED, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRT_done() {
|
void CRT_done() {
|
||||||
|
2
CRT.h
2
CRT.h
@ -115,6 +115,8 @@ void CRT_fatalError(const char* note) __attribute__ ((noreturn));
|
|||||||
|
|
||||||
void CRT_handleSIGSEGV(int sgn);
|
void CRT_handleSIGSEGV(int sgn);
|
||||||
|
|
||||||
|
#define KEY_ALT(x) KEY_F(60) + (x - 'A')
|
||||||
|
|
||||||
|
|
||||||
extern const char *CRT_treeStrAscii[TREE_STR_COUNT];
|
extern const char *CRT_treeStrAscii[TREE_STR_COUNT];
|
||||||
|
|
||||||
|
19
ChangeLog
19
ChangeLog
@ -1,4 +1,23 @@
|
|||||||
|
|
||||||
|
What's new in version 2.0.1
|
||||||
|
|
||||||
|
* OpenBSD: Various fixes and improvements
|
||||||
|
(thanks to Michael McConville and Juan Francisco Cantero Hurtado)
|
||||||
|
* FreeBSD: fix CPU and memory readings
|
||||||
|
(thanks to Tim Creech, Hung-Yi Chen, Bernard Spil, Greg V)
|
||||||
|
* FreeBSD: add battery support
|
||||||
|
(thanks to Greg V)
|
||||||
|
* Linux: Retain last-obtained name of a zombie process
|
||||||
|
* Mac OS X: Improve portability for OS X versions
|
||||||
|
(thanks to Michael Klein)
|
||||||
|
* Mac OS X: Fix reading command-line arguments and basename
|
||||||
|
* Mac OS X: Fix process state information
|
||||||
|
* Mac OS X: Fix tree view collapsing/expanding
|
||||||
|
* Mac OS X: Fix tree organization
|
||||||
|
* Mac OS X: Fix memory accounting
|
||||||
|
* Fix crash when emptying a column of meters
|
||||||
|
* Make Esc key more responsive
|
||||||
|
|
||||||
What's new in version 2.0.0
|
What's new in version 2.0.0
|
||||||
|
|
||||||
* Platform abstraction layer
|
* Platform abstraction layer
|
||||||
|
233
INSTALL
233
INSTALL
@ -1,13 +1,25 @@
|
|||||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
Installation Instructions
|
||||||
Foundation, Inc.
|
*************************
|
||||||
|
|
||||||
This file is free documentation; the Free Software Foundation gives
|
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
|
||||||
unlimited permission to copy, distribute and modify it.
|
Inc.
|
||||||
|
|
||||||
|
Copying and distribution of this file, with or without modification,
|
||||||
|
are permitted in any medium without royalty provided the copyright
|
||||||
|
notice and this notice are preserved. This file is offered as-is,
|
||||||
|
without warranty of any kind.
|
||||||
|
|
||||||
Basic Installation
|
Basic Installation
|
||||||
==================
|
==================
|
||||||
|
|
||||||
These are generic installation instructions.
|
Briefly, the shell commands `./configure; make; make install' should
|
||||||
|
configure, build, and install this package. The following
|
||||||
|
more-detailed instructions are generic; see the `README' file for
|
||||||
|
instructions specific to this package. Some packages provide this
|
||||||
|
`INSTALL' file but do not implement all of the features documented
|
||||||
|
below. The lack of an optional feature in a given package is not
|
||||||
|
necessarily a bug. More recommendations for GNU packages can be found
|
||||||
|
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||||
|
|
||||||
The `configure' shell script attempts to guess correct values for
|
The `configure' shell script attempts to guess correct values for
|
||||||
various system-dependent variables used during compilation. It uses
|
various system-dependent variables used during compilation. It uses
|
||||||
@ -20,9 +32,9 @@ debugging `configure').
|
|||||||
|
|
||||||
It can also use an optional file (typically called `config.cache'
|
It can also use an optional file (typically called `config.cache'
|
||||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||||
the results of its tests to speed up reconfiguring. (Caching is
|
the results of its tests to speed up reconfiguring. Caching is
|
||||||
disabled by default to prevent problems with accidental use of stale
|
disabled by default to prevent problems with accidental use of stale
|
||||||
cache files.)
|
cache files.
|
||||||
|
|
||||||
If you need to do unusual things to compile the package, please try
|
If you need to do unusual things to compile the package, please try
|
||||||
to figure out how `configure' could check whether to do them, and mail
|
to figure out how `configure' could check whether to do them, and mail
|
||||||
@ -32,30 +44,37 @@ some point `config.cache' contains results you don't want to keep, you
|
|||||||
may remove or edit it.
|
may remove or edit it.
|
||||||
|
|
||||||
The file `configure.ac' (or `configure.in') is used to create
|
The file `configure.ac' (or `configure.in') is used to create
|
||||||
`configure' by a program called `autoconf'. You only need
|
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||||
`configure.ac' if you want to change it or regenerate `configure' using
|
you want to change it or regenerate `configure' using a newer version
|
||||||
a newer version of `autoconf'.
|
of `autoconf'.
|
||||||
|
|
||||||
The simplest way to compile this package is:
|
The simplest way to compile this package is:
|
||||||
|
|
||||||
1. `cd' to the directory containing the package's source code and type
|
1. `cd' to the directory containing the package's source code and type
|
||||||
`./configure' to configure the package for your system. If you're
|
`./configure' to configure the package for your system.
|
||||||
using `csh' on an old version of System V, you might need to type
|
|
||||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
|
||||||
`configure' itself.
|
|
||||||
|
|
||||||
Running `configure' takes awhile. While running, it prints some
|
Running `configure' might take a while. While running, it prints
|
||||||
messages telling which features it is checking for.
|
some messages telling which features it is checking for.
|
||||||
|
|
||||||
2. Type `make' to compile the package.
|
2. Type `make' to compile the package.
|
||||||
|
|
||||||
3. Optionally, type `make check' to run any self-tests that come with
|
3. Optionally, type `make check' to run any self-tests that come with
|
||||||
the package.
|
the package, generally using the just-built uninstalled binaries.
|
||||||
|
|
||||||
4. Type `make install' to install the programs and any data files and
|
4. Type `make install' to install the programs and any data files and
|
||||||
documentation.
|
documentation. When installing into a prefix owned by root, it is
|
||||||
|
recommended that the package be configured and built as a regular
|
||||||
|
user, and only the `make install' phase executed with root
|
||||||
|
privileges.
|
||||||
|
|
||||||
5. You can remove the program binaries and object files from the
|
5. Optionally, type `make installcheck' to repeat any self-tests, but
|
||||||
|
this time using the binaries in their final installed location.
|
||||||
|
This target does not install anything. Running this target as a
|
||||||
|
regular user, particularly if the prior `make install' required
|
||||||
|
root privileges, verifies that the installation completed
|
||||||
|
correctly.
|
||||||
|
|
||||||
|
6. You can remove the program binaries and object files from the
|
||||||
source code directory by typing `make clean'. To also remove the
|
source code directory by typing `make clean'. To also remove the
|
||||||
files that `configure' created (so you can compile the package for
|
files that `configure' created (so you can compile the package for
|
||||||
a different kind of computer), type `make distclean'. There is
|
a different kind of computer), type `make distclean'. There is
|
||||||
@ -64,6 +83,16 @@ The simplest way to compile this package is:
|
|||||||
all sorts of other programs in order to regenerate files that came
|
all sorts of other programs in order to regenerate files that came
|
||||||
with the distribution.
|
with the distribution.
|
||||||
|
|
||||||
|
7. Often, you can also type `make uninstall' to remove the installed
|
||||||
|
files again. In practice, not all packages have tested that
|
||||||
|
uninstallation works correctly, even though it is required by the
|
||||||
|
GNU Coding Standards.
|
||||||
|
|
||||||
|
8. Some packages, particularly those that use Automake, provide `make
|
||||||
|
distcheck', which can by used by developers to test that all other
|
||||||
|
targets like `make install' and `make uninstall' work correctly.
|
||||||
|
This target is generally not run by end users.
|
||||||
|
|
||||||
Compilers and Options
|
Compilers and Options
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
@ -75,7 +104,7 @@ for details on some of the pertinent environment variables.
|
|||||||
by setting variables in the command line or in the environment. Here
|
by setting variables in the command line or in the environment. Here
|
||||||
is an example:
|
is an example:
|
||||||
|
|
||||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||||
|
|
||||||
*Note Defining Variables::, for more details.
|
*Note Defining Variables::, for more details.
|
||||||
|
|
||||||
@ -84,44 +113,89 @@ Compiling For Multiple Architectures
|
|||||||
|
|
||||||
You can compile the package for more than one kind of computer at the
|
You can compile the package for more than one kind of computer at the
|
||||||
same time, by placing the object files for each architecture in their
|
same time, by placing the object files for each architecture in their
|
||||||
own directory. To do this, you must use a version of `make' that
|
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
|
||||||
directory where you want the object files and executables to go and run
|
directory where you want the object files and executables to go and run
|
||||||
the `configure' script. `configure' automatically checks for the
|
the `configure' script. `configure' automatically checks for the
|
||||||
source code in the directory that `configure' is in and in `..'.
|
source code in the directory that `configure' is in and in `..'. This
|
||||||
|
is known as a "VPATH" build.
|
||||||
|
|
||||||
If you have to use a `make' that does not support the `VPATH'
|
With a non-GNU `make', it is safer to compile the package for one
|
||||||
variable, you have to compile the package for one architecture at a
|
architecture at a time in the source code directory. After you have
|
||||||
time in the source code directory. After you have installed the
|
installed the package for one architecture, use `make distclean' before
|
||||||
package for one architecture, use `make distclean' before reconfiguring
|
reconfiguring for another architecture.
|
||||||
for another architecture.
|
|
||||||
|
On MacOS X 10.5 and later systems, you can create libraries and
|
||||||
|
executables that work on multiple system types--known as "fat" or
|
||||||
|
"universal" binaries--by specifying multiple `-arch' options to the
|
||||||
|
compiler but only a single `-arch' option to the preprocessor. Like
|
||||||
|
this:
|
||||||
|
|
||||||
|
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||||
|
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||||
|
CPP="gcc -E" CXXCPP="g++ -E"
|
||||||
|
|
||||||
|
This is not guaranteed to produce working output in all cases, you
|
||||||
|
may have to build one architecture at a time and combine the results
|
||||||
|
using the `lipo' tool if you have problems.
|
||||||
|
|
||||||
Installation Names
|
Installation Names
|
||||||
==================
|
==================
|
||||||
|
|
||||||
By default, `make install' will install the package's files in
|
By default, `make install' installs the package's commands under
|
||||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||||
installation prefix other than `/usr/local' by giving `configure' the
|
can specify an installation prefix other than `/usr/local' by giving
|
||||||
option `--prefix=PATH'.
|
`configure' the option `--prefix=PREFIX', where PREFIX must be an
|
||||||
|
absolute file name.
|
||||||
|
|
||||||
You can specify separate installation prefixes for
|
You can specify separate installation prefixes for
|
||||||
architecture-specific files and architecture-independent files. If you
|
architecture-specific files and architecture-independent files. If you
|
||||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||||
PATH as the prefix for installing programs and libraries.
|
PREFIX as the prefix for installing programs and libraries.
|
||||||
Documentation and other data files will still use the regular prefix.
|
Documentation and other data files still use the regular prefix.
|
||||||
|
|
||||||
In addition, if you use an unusual directory layout you can give
|
In addition, if you use an unusual directory layout you can give
|
||||||
options like `--bindir=PATH' to specify different values for particular
|
options like `--bindir=DIR' to specify different values for particular
|
||||||
kinds of files. Run `configure --help' for a list of the directories
|
kinds of files. Run `configure --help' for a list of the directories
|
||||||
you can set and what kinds of files go in them.
|
you can set and what kinds of files go in them. In general, the
|
||||||
|
default for these options is expressed in terms of `${prefix}', so that
|
||||||
|
specifying just `--prefix' will affect all of the other directory
|
||||||
|
specifications that were not explicitly provided.
|
||||||
|
|
||||||
|
The most portable way to affect installation locations is to pass the
|
||||||
|
correct locations to `configure'; however, many packages provide one or
|
||||||
|
both of the following shortcuts of passing variable assignments to the
|
||||||
|
`make install' command line to change installation locations without
|
||||||
|
having to reconfigure or recompile.
|
||||||
|
|
||||||
|
The first method involves providing an override variable for each
|
||||||
|
affected directory. For example, `make install
|
||||||
|
prefix=/alternate/directory' will choose an alternate location for all
|
||||||
|
directory configuration variables that were expressed in terms of
|
||||||
|
`${prefix}'. Any directories that were specified during `configure',
|
||||||
|
but not in terms of `${prefix}', must each be overridden at install
|
||||||
|
time for the entire installation to be relocated. The approach of
|
||||||
|
makefile variable overrides for each directory variable is required by
|
||||||
|
the GNU Coding Standards, and ideally causes no recompilation.
|
||||||
|
However, some platforms have known limitations with the semantics of
|
||||||
|
shared libraries that end up requiring recompilation when using this
|
||||||
|
method, particularly noticeable in packages that use GNU Libtool.
|
||||||
|
|
||||||
|
The second method involves providing the `DESTDIR' variable. For
|
||||||
|
example, `make install DESTDIR=/alternate/directory' will prepend
|
||||||
|
`/alternate/directory' before all installation names. The approach of
|
||||||
|
`DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||||
|
does not work on platforms that have drive letters. On the other hand,
|
||||||
|
it does better at avoiding recompilation issues, and works well even
|
||||||
|
when some directory options were not specified in terms of `${prefix}'
|
||||||
|
at `configure' time.
|
||||||
|
|
||||||
|
Optional Features
|
||||||
|
=================
|
||||||
|
|
||||||
If the package supports it, you can cause programs to be installed
|
If the package supports it, you can cause programs to be installed
|
||||||
with an extra prefix or suffix on their names by giving `configure' the
|
with an extra prefix or suffix on their names by giving `configure' the
|
||||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||||
|
|
||||||
Optional Features
|
|
||||||
=================
|
|
||||||
|
|
||||||
Some packages pay attention to `--enable-FEATURE' options to
|
Some packages pay attention to `--enable-FEATURE' options to
|
||||||
`configure', where FEATURE indicates an optional part of the package.
|
`configure', where FEATURE indicates an optional part of the package.
|
||||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||||
@ -134,6 +208,50 @@ find the X include and library files automatically, but if it doesn't,
|
|||||||
you can use the `configure' options `--x-includes=DIR' and
|
you can use the `configure' options `--x-includes=DIR' and
|
||||||
`--x-libraries=DIR' to specify their locations.
|
`--x-libraries=DIR' to specify their locations.
|
||||||
|
|
||||||
|
Some packages offer the ability to configure how verbose the
|
||||||
|
execution of `make' will be. For these packages, running `./configure
|
||||||
|
--enable-silent-rules' sets the default to minimal output, which can be
|
||||||
|
overridden with `make V=1'; while running `./configure
|
||||||
|
--disable-silent-rules' sets the default to verbose, which can be
|
||||||
|
overridden with `make V=0'.
|
||||||
|
|
||||||
|
Particular systems
|
||||||
|
==================
|
||||||
|
|
||||||
|
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||||
|
CC is not installed, it is recommended to use the following options in
|
||||||
|
order to use an ANSI C compiler:
|
||||||
|
|
||||||
|
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||||
|
|
||||||
|
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||||
|
|
||||||
|
HP-UX `make' updates targets which have the same time stamps as
|
||||||
|
their prerequisites, which makes it generally unusable when shipped
|
||||||
|
generated files such as `configure' are involved. Use GNU `make'
|
||||||
|
instead.
|
||||||
|
|
||||||
|
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||||
|
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
|
||||||
|
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||||
|
to try
|
||||||
|
|
||||||
|
./configure CC="cc"
|
||||||
|
|
||||||
|
and if that doesn't work, try
|
||||||
|
|
||||||
|
./configure CC="cc -nodtk"
|
||||||
|
|
||||||
|
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
|
||||||
|
directory contains several dysfunctional programs; working variants of
|
||||||
|
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
|
||||||
|
in your `PATH', put it _after_ `/usr/bin'.
|
||||||
|
|
||||||
|
On Haiku, software installed for all users goes in `/boot/common',
|
||||||
|
not `/usr/local'. It is recommended to use the following options:
|
||||||
|
|
||||||
|
./configure --prefix=/boot/common
|
||||||
|
|
||||||
Specifying the System Type
|
Specifying the System Type
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
@ -149,14 +267,15 @@ type, such as `sun4', or a canonical name which has the form:
|
|||||||
|
|
||||||
where SYSTEM can have one of these forms:
|
where SYSTEM can have one of these forms:
|
||||||
|
|
||||||
OS KERNEL-OS
|
OS
|
||||||
|
KERNEL-OS
|
||||||
|
|
||||||
See the file `config.sub' for the possible values of each field. If
|
See the file `config.sub' for the possible values of each field. If
|
||||||
`config.sub' isn't included in this package, then this package doesn't
|
`config.sub' isn't included in this package, then this package doesn't
|
||||||
need to know the machine type.
|
need to know the machine type.
|
||||||
|
|
||||||
If you are _building_ compiler tools for cross-compiling, you should
|
If you are _building_ compiler tools for cross-compiling, you should
|
||||||
use the `--target=TYPE' option to select the type of system they will
|
use the option `--target=TYPE' to select the type of system they will
|
||||||
produce code for.
|
produce code for.
|
||||||
|
|
||||||
If you want to _use_ a cross compiler, that generates code for a
|
If you want to _use_ a cross compiler, that generates code for a
|
||||||
@ -186,9 +305,15 @@ them in the `configure' command line, using `VAR=value'. For example:
|
|||||||
|
|
||||||
./configure CC=/usr/local2/bin/gcc
|
./configure CC=/usr/local2/bin/gcc
|
||||||
|
|
||||||
will cause the specified gcc to be used as the C compiler (unless it is
|
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||||
overridden in the site shell script).
|
overridden in the site shell script).
|
||||||
|
|
||||||
|
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||||
|
an Autoconf limitation. Until the limitation is lifted, you can use
|
||||||
|
this workaround:
|
||||||
|
|
||||||
|
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||||
|
|
||||||
`configure' Invocation
|
`configure' Invocation
|
||||||
======================
|
======================
|
||||||
|
|
||||||
@ -197,7 +322,14 @@ operates.
|
|||||||
|
|
||||||
`--help'
|
`--help'
|
||||||
`-h'
|
`-h'
|
||||||
Print a summary of the options to `configure', and exit.
|
Print a summary of all of the options to `configure', and exit.
|
||||||
|
|
||||||
|
`--help=short'
|
||||||
|
`--help=recursive'
|
||||||
|
Print a summary of the options unique to this package's
|
||||||
|
`configure', and exit. The `short' variant lists options used
|
||||||
|
only in the top level, while the `recursive' variant lists options
|
||||||
|
also present in any nested packages.
|
||||||
|
|
||||||
`--version'
|
`--version'
|
||||||
`-V'
|
`-V'
|
||||||
@ -224,6 +356,15 @@ operates.
|
|||||||
Look for the package's source code in directory DIR. Usually
|
Look for the package's source code in directory DIR. Usually
|
||||||
`configure' can determine that directory automatically.
|
`configure' can determine that directory automatically.
|
||||||
|
|
||||||
|
`--prefix=DIR'
|
||||||
|
Use DIR as the installation prefix. *note Installation Names::
|
||||||
|
for more details, including other options available for fine-tuning
|
||||||
|
the installation locations.
|
||||||
|
|
||||||
|
`--no-create'
|
||||||
|
`-n'
|
||||||
|
Run the configure checks, but stop before creating any output
|
||||||
|
files.
|
||||||
|
|
||||||
`configure' also accepts some other, not widely useful, options. Run
|
`configure' also accepts some other, not widely useful, options. Run
|
||||||
`configure --help' for more details.
|
`configure --help' for more details.
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ void InfoScreen_run(InfoScreen* this) {
|
|||||||
|
|
||||||
if (this->inc->active)
|
if (this->inc->active)
|
||||||
move(LINES-1, CRT_cursorX);
|
move(LINES-1, CRT_cursorX);
|
||||||
|
ESCDELAY = 25;
|
||||||
int ch = getch();
|
int ch = getch();
|
||||||
|
|
||||||
if (ch == ERR) {
|
if (ch == ERR) {
|
||||||
|
@ -95,7 +95,7 @@ debug:
|
|||||||
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-ggdb -DDEBUG"
|
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-ggdb -DDEBUG"
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" AM_LDFLAGS="-lgcov"
|
$(MAKE) all CFLAGS="" AM_CPPFLAGS="-fprofile-arcs -ftest-coverage -DDEBUG" LDFLAGS="-lgcov"
|
||||||
|
|
||||||
.c.h:
|
.c.h:
|
||||||
@srcdir@/scripts/MakeHeader.py $<
|
@srcdir@/scripts/MakeHeader.py $<
|
||||||
|
@ -50,7 +50,10 @@ static void MetersPanel_delete(Object* object) {
|
|||||||
void MetersPanel_setMoving(MetersPanel* this, bool moving) {
|
void MetersPanel_setMoving(MetersPanel* this, bool moving) {
|
||||||
Panel* super = (Panel*) this;
|
Panel* super = (Panel*) this;
|
||||||
this->moving = moving;
|
this->moving = moving;
|
||||||
((ListItem*)Panel_getSelected(super))->moving = moving;
|
ListItem* selected = (ListItem*)Panel_getSelected(super);
|
||||||
|
if (selected) {
|
||||||
|
selected->moving = moving;
|
||||||
|
}
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]);
|
Panel_setSelectionColor(super, CRT_colors[PANEL_SELECTION_FOCUS]);
|
||||||
Panel_setDefaultBar(super);
|
Panel_setDefaultBar(super);
|
||||||
|
2
Panel.c
2
Panel.c
@ -441,7 +441,7 @@ bool Panel_onKey(Panel* this, int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ensure selection within bounds
|
// ensure selection within bounds
|
||||||
if (this->selected < 0) {
|
if (this->selected < 0 || size == 0) {
|
||||||
this->selected = 0;
|
this->selected = 0;
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
} else if (this->selected >= size) {
|
} else if (this->selected >= size) {
|
||||||
|
@ -335,7 +335,10 @@ void Process_outputRate(RichString* str, char* buffer, int n, double rate, int c
|
|||||||
largeNumberColor = CRT_colors[PROCESS];
|
largeNumberColor = CRT_colors[PROCESS];
|
||||||
processMegabytesColor = CRT_colors[PROCESS];
|
processMegabytesColor = CRT_colors[PROCESS];
|
||||||
}
|
}
|
||||||
if (rate < ONE_K) {
|
if (rate == -1) {
|
||||||
|
int len = snprintf(buffer, n, " no perm ");
|
||||||
|
RichString_appendn(str, CRT_colors[PROCESS_SHADOW], buffer, len);
|
||||||
|
} else if (rate < ONE_K) {
|
||||||
int len = snprintf(buffer, n, "%7.2f B/s ", rate);
|
int len = snprintf(buffer, n, "%7.2f B/s ", rate);
|
||||||
RichString_appendn(str, processColor, buffer, len);
|
RichString_appendn(str, processColor, buffer, len);
|
||||||
} else if (rate < ONE_K * ONE_K) {
|
} else if (rate < ONE_K * ONE_K) {
|
||||||
|
@ -22,6 +22,10 @@ in the source distribution for its full text.
|
|||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
#include <hwloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_NAME
|
#ifndef MAX_NAME
|
||||||
#define MAX_NAME 128
|
#define MAX_NAME 128
|
||||||
#endif
|
#endif
|
||||||
@ -104,6 +108,11 @@ ProcessList* ProcessList_init(ProcessList* this, ObjectClass* klass, UsersTable*
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList_done(ProcessList* this) {
|
void ProcessList_done(ProcessList* this) {
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
if (this->topologyOk) {
|
||||||
|
hwloc_topology_destroy(this->topology);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Hashtable_delete(this->processTable);
|
Hashtable_delete(this->processTable);
|
||||||
Vector_delete(this->processes);
|
Vector_delete(this->processes);
|
||||||
Vector_delete(this->processes2);
|
Vector_delete(this->processes2);
|
||||||
@ -307,6 +316,7 @@ void ProcessList_scan(ProcessList* this) {
|
|||||||
for (int i = 0; i < Vector_size(this->processes); i++) {
|
for (int i = 0; i < Vector_size(this->processes); i++) {
|
||||||
Process* p = (Process*) Vector_get(this->processes, i);
|
Process* p = (Process*) Vector_get(this->processes, i);
|
||||||
p->updated = false;
|
p->updated = false;
|
||||||
|
p->show = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->totalTasks = 0;
|
this->totalTasks = 0;
|
||||||
|
@ -16,6 +16,10 @@ in the source distribution for its full text.
|
|||||||
#include "Process.h"
|
#include "Process.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBHWLOC
|
||||||
|
#include <hwloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAX_NAME
|
#ifndef MAX_NAME
|
||||||
#define MAX_NAME 128
|
#define MAX_NAME 128
|
||||||
#endif
|
#endif
|
||||||
|
59
README
59
README
@ -1,50 +1,61 @@
|
|||||||
htop
|
[](https://travis-ci.org/hishamhm/htop)
|
||||||
|
[](http://hisham.hm/htop/index.php?page=donate)
|
||||||
|
|
||||||
|
[htop](http://hisham.hm/htop/)
|
||||||
====
|
====
|
||||||
|
|
||||||
by Hisham Muhammad <hisham@gobolinux.org>
|
by Hisham Muhammad <hisham@gobolinux.org> (2004 - 2016)
|
||||||
|
|
||||||
2004 - 2015
|
|
||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
This is htop, an interactive process viewer.
|
This is `htop`, an interactive process viewer.
|
||||||
It requires ncurses. It is developed primarily on Linux,
|
It requires `ncurses`. It is developed primarily on Linux,
|
||||||
but we also have code for running under FreeBSD and Mac OS X
|
but we also have code for running under FreeBSD and Mac OS X
|
||||||
(help and testing are wanted for these platforms!)
|
(help and testing are wanted for these platforms!)
|
||||||
|
|
||||||
This software has evolved considerably over the years,
|
This software has evolved considerably over the years,
|
||||||
and is reasonably complete, but there is always room for improvement.
|
and is reasonably complete, but there is always room for improvement.
|
||||||
|
|
||||||
Comparison between 'htop' and classic 'top'
|
Comparison between `htop` and classic `top`
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
* In 'htop' you can scroll the list vertically and horizontally
|
* In `htop` you can scroll the list vertically and horizontally
|
||||||
to see all processes and full command lines.
|
to see all processes and full command lines.
|
||||||
* In 'top' you are subject to a delay for each unassigned
|
* In `top` you are subject to a delay for each unassigned
|
||||||
key you press (especially annoying when multi-key escape
|
key you press (especially annoying when multi-key escape
|
||||||
sequences are triggered by accident).
|
sequences are triggered by accident).
|
||||||
* 'htop' starts faster ('top' seems to collect data for a while
|
* `htop` starts faster (`top` seems to collect data for a while
|
||||||
before displaying anything).
|
before displaying anything).
|
||||||
* In 'htop' you don't need to type the process number to
|
* In `htop` you don't need to type the process number to
|
||||||
kill a process, in 'top' you do.
|
kill a process, in `top` you do.
|
||||||
* In 'htop' you don't need to type the process number or
|
* In `htop` you don't need to type the process number or
|
||||||
the priority value to renice a process, in 'top' you do.
|
the priority value to renice a process, in `top` you do.
|
||||||
* In 'htop' you can kill multiple processes at once.
|
* In `htop` you can kill multiple processes at once.
|
||||||
* 'top' is older, hence, more tested.
|
* `top` is older, hence, more tested.
|
||||||
|
|
||||||
Compilation instructions
|
Compilation instructions
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
This program is distributed as a standard autotools-based package.
|
This program is distributed as a standard autotools-based package.
|
||||||
See the INSTALL file for detailed instructions, but you are
|
See the [INSTALL](/INSTALL) file for detailed instructions.
|
||||||
probably used to the common `./configure`/`make`/`make install` routine.
|
|
||||||
|
|
||||||
When fetching the code from the development repository, you need
|
When compiling from a release tarball, run:
|
||||||
to run the `./autogen.sh` script, which in turn requires autotools
|
|
||||||
to be installed.
|
|
||||||
|
|
||||||
See the manual page (man htop) or the on-line help ('F1' or 'h'
|
./configure && make
|
||||||
inside htop) for a list of supported key commands.
|
|
||||||
|
|
||||||
if not all keys work check your curses configuration.
|
For compiling sources downloaded from the Git repository, run:
|
||||||
|
|
||||||
|
./autogen.sh && ./configure && make
|
||||||
|
|
||||||
|
By default `make install` will install into `/usr/local`, for changing
|
||||||
|
the path use `./configure --prefix=/some/path`.
|
||||||
|
|
||||||
|
See the manual page (`man htop`) or the on-line help ('F1' or 'h'
|
||||||
|
inside `htop`) for a list of supported key commands.
|
||||||
|
|
||||||
|
If not all keys work check your curses configuration.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
@ -189,6 +189,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int prevCh = ch;
|
int prevCh = ch;
|
||||||
|
ESCDELAY = 25;
|
||||||
ch = getch();
|
ch = getch();
|
||||||
|
|
||||||
HandlerResult result = IGNORED;
|
HandlerResult result = IGNORED;
|
||||||
@ -244,28 +245,11 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
|||||||
redraw = false;
|
redraw = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (ch == 27) {
|
switch (ch) {
|
||||||
int ch2 = getch();
|
case KEY_ALT('H'): ch = KEY_LEFT; break;
|
||||||
if (ch2 != ERR) {
|
case KEY_ALT('J'): ch = KEY_DOWN; break;
|
||||||
switch(ch2)
|
case KEY_ALT('K'): ch = KEY_UP; break;
|
||||||
{
|
case KEY_ALT('L'): ch = KEY_RIGHT; break;
|
||||||
case 'h':
|
|
||||||
ch = KEY_LEFT;
|
|
||||||
break;
|
|
||||||
case 'j':
|
|
||||||
ch = KEY_DOWN;
|
|
||||||
break;
|
|
||||||
case 'k':
|
|
||||||
ch = KEY_UP;
|
|
||||||
break;
|
|
||||||
case 'l':
|
|
||||||
ch = KEY_RIGHT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ungetch(ch2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
redraw = true;
|
redraw = true;
|
||||||
if (Panel_eventHandlerFn(panelFocus)) {
|
if (Panel_eventHandlerFn(panelFocus)) {
|
||||||
|
14
autogen.sh
14
autogen.sh
@ -1,15 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
glibtoolize=$(which glibtoolize 2> /dev/null)
|
|
||||||
if [ ${#glibtoolize} -gt 0 ]
|
|
||||||
then libtoolize=glibtoolize
|
|
||||||
else libtoolize=libtoolize
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p m4
|
mkdir -p m4
|
||||||
aclocal -I m4
|
autoreconf --install --force
|
||||||
autoconf
|
|
||||||
autoheader
|
|
||||||
$libtoolize --copy --force
|
|
||||||
automake --add-missing --copy
|
|
||||||
|
|
||||||
|
14
configure.ac
14
configure.ac
@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.65)
|
AC_PREREQ(2.65)
|
||||||
AC_INIT([htop],[2.0.0],[hisham@gobolinux.org])
|
AC_INIT([htop],[2.0.1],[hisham@gobolinux.org])
|
||||||
|
|
||||||
year=$(date +%Y)
|
year=$(date +%Y)
|
||||||
|
|
||||||
@ -211,8 +211,8 @@ if test "$my_htop_platform" = "openbsd"; then
|
|||||||
AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
|
AC_CHECK_LIB([kvm], [kvm_open], [], [missing_libraries="$missing_libraries libkvm"])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_ENABLE(native_affinity, [AC_HELP_STRING([--enable-native-affinity], [enable native sched_setaffinity and sched_getaffinity for affinity support, disables hwloc])], ,enable_native_affinity="yes")
|
AC_ARG_ENABLE(linux_affinity, [AC_HELP_STRING([--enable-linux-affinity], [enable Linux sched_setaffinity and sched_getaffinity for affinity support, disables hwloc])], ,enable_linux_affinity="yes")
|
||||||
if test "x$enable_native_affinity" = xyes -a "x$cross_compiling" = xno; then
|
if test "x$enable_linux_affinity" = xyes -a "x$cross_compiling" = xno; then
|
||||||
AC_MSG_CHECKING([for usable sched_setaffinity])
|
AC_MSG_CHECKING([for usable sched_setaffinity])
|
||||||
AC_RUN_IFELSE([
|
AC_RUN_IFELSE([
|
||||||
AC_LANG_PROGRAM([[
|
AC_LANG_PROGRAM([[
|
||||||
@ -225,17 +225,17 @@ if test "x$enable_native_affinity" = xyes -a "x$cross_compiling" = xno; then
|
|||||||
if (errno == ENOSYS) return 1;
|
if (errno == ENOSYS) return 1;
|
||||||
]])],
|
]])],
|
||||||
[AC_MSG_RESULT([yes])],
|
[AC_MSG_RESULT([yes])],
|
||||||
[enable_native_affinity=no
|
[enable_linux_affinity=no
|
||||||
AC_MSG_RESULT([no])])
|
AC_MSG_RESULT([no])])
|
||||||
fi
|
fi
|
||||||
if test "x$enable_native_affinity" = xyes; then
|
if test "x$enable_linux_affinity" = xyes; then
|
||||||
AC_DEFINE(HAVE_NATIVE_AFFINITY, 1, [Define if native sched_setaffinity and sched_getaffinity are to be used.])
|
AC_DEFINE(HAVE_LINUX_AFFINITY, 1, [Define if Linux sched_setaffinity and sched_getaffinity are to be used.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_ENABLE(hwloc, [AC_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
|
AC_ARG_ENABLE(hwloc, [AC_HELP_STRING([--enable-hwloc], [enable hwloc support for CPU affinity])],, enable_hwloc="no")
|
||||||
if test "x$enable_hwloc" = xyes
|
if test "x$enable_hwloc" = xyes
|
||||||
then
|
then
|
||||||
AC_CHECK_LIB([hwloc], [hwloc_linux_get_tid_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
|
AC_CHECK_LIB([hwloc], [hwloc_get_proc_cpubind], [], [missing_libraries="$missing_libraries libhwloc"])
|
||||||
AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
|
AC_CHECK_HEADERS([hwloc.h],[:], [missing_headers="$missing_headers $ac_header"])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ in the source distribution for its full text.
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <mach/mach.h>
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
#include "DarwinProcessList.h"
|
#include "DarwinProcessList.h"
|
||||||
@ -69,7 +71,7 @@ void DarwinProcess_setStartTime(Process *proc, struct extern_proc *ep, time_t no
|
|||||||
strftime(proc->starttime_show, 7, ((proc->starttime_ctime > now - 86400) ? "%R " : "%b%d "), &date);
|
strftime(proc->starttime_show, 7, ((proc->starttime_ctime > now - 86400) ? "%R " : "%b%d "), &date);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
|
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) {
|
||||||
/* This function is from the old Mac version of htop. Originally from ps? */
|
/* This function is from the old Mac version of htop. Originally from ps? */
|
||||||
int mib[3], argmax, nargs, c = 0;
|
int mib[3], argmax, nargs, c = 0;
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -167,13 +169,7 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
|
|||||||
/* Save where the argv[0] string starts. */
|
/* Save where the argv[0] string starts. */
|
||||||
sp = cp;
|
sp = cp;
|
||||||
|
|
||||||
/*
|
*basenameOffset = 0;
|
||||||
* Iterate through the '\0'-terminated strings and convert '\0' to ' '
|
|
||||||
* until a string is found that has a '=' character in it (or there are
|
|
||||||
* no more strings in procargs). There is no way to deterministically
|
|
||||||
* know where the command arguments end and the environment strings
|
|
||||||
* start, which is why the '=' character is searched for as a heuristic.
|
|
||||||
*/
|
|
||||||
for ( np = NULL; c < nargs && cp < &procargs[size]; cp++ ) {
|
for ( np = NULL; c < nargs && cp < &procargs[size]; cp++ ) {
|
||||||
if ( *cp == '\0' ) {
|
if ( *cp == '\0' ) {
|
||||||
c++;
|
c++;
|
||||||
@ -183,49 +179,11 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
|
|||||||
}
|
}
|
||||||
/* Note location of current '\0'. */
|
/* Note location of current '\0'. */
|
||||||
np = cp;
|
np = cp;
|
||||||
|
if (*basenameOffset == 0) {
|
||||||
if ( !show_args ) {
|
*basenameOffset = cp - sp;
|
||||||
/*
|
|
||||||
* Don't convert '\0' characters to ' '.
|
|
||||||
* However, we needed to know that the
|
|
||||||
* command name was terminated, which we
|
|
||||||
* now know.
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* If eflg is non-zero, continue converting '\0' characters to ' '
|
|
||||||
* characters until no more strings that look like environment settings
|
|
||||||
* follow.
|
|
||||||
*/
|
|
||||||
if ( ( eflg != 0 )
|
|
||||||
&& ( ( getuid( ) == 0 )
|
|
||||||
|| ( k->kp_eproc.e_pcred.p_ruid == getuid( ) ) ) ) {
|
|
||||||
for ( ; cp < &procargs[size]; cp++ ) {
|
|
||||||
if ( *cp == '\0' ) {
|
|
||||||
if ( np != NULL ) {
|
|
||||||
if ( &np[1] == cp ) {
|
|
||||||
/*
|
|
||||||
* Two '\0' characters in a row.
|
|
||||||
* This should normally only
|
|
||||||
* happen after all the strings
|
|
||||||
* have been seen, but in any
|
|
||||||
* case, stop parsing.
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* Convert previous '\0'. */
|
|
||||||
*np = ' ';
|
|
||||||
}
|
|
||||||
/* Note location of current '\0'. */
|
|
||||||
np = cp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sp points to the beginning of the arguments/environment string, and
|
* sp points to the beginning of the arguments/environment string, and
|
||||||
@ -235,6 +193,9 @@ char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args ) {
|
|||||||
/* Empty or unterminated string. */
|
/* Empty or unterminated string. */
|
||||||
goto ERROR_B;
|
goto ERROR_B;
|
||||||
}
|
}
|
||||||
|
if (*basenameOffset == 0) {
|
||||||
|
*basenameOffset = np - sp;
|
||||||
|
}
|
||||||
|
|
||||||
/* Make a copy of the string. */
|
/* Make a copy of the string. */
|
||||||
retval = xStrdup(sp);
|
retval = xStrdup(sp);
|
||||||
@ -248,7 +209,8 @@ ERROR_B:
|
|||||||
free( procargs );
|
free( procargs );
|
||||||
ERROR_A:
|
ERROR_A:
|
||||||
retval = xStrdup(k->kp_proc.p_comm);
|
retval = xStrdup(k->kp_proc.p_comm);
|
||||||
|
*basenameOffset = strlen(retval);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,35 +237,22 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, time_t
|
|||||||
proc->ppid = ps->kp_eproc.e_ppid;
|
proc->ppid = ps->kp_eproc.e_ppid;
|
||||||
proc->pgrp = ps->kp_eproc.e_pgid;
|
proc->pgrp = ps->kp_eproc.e_pgid;
|
||||||
proc->session = 0; /* TODO Get the session id */
|
proc->session = 0; /* TODO Get the session id */
|
||||||
proc->tgid = ps->kp_eproc.e_tpgid;
|
proc->tpgid = ps->kp_eproc.e_tpgid;
|
||||||
|
proc->tgid = proc->pid;
|
||||||
proc->st_uid = ps->kp_eproc.e_ucred.cr_uid;
|
proc->st_uid = ps->kp_eproc.e_ucred.cr_uid;
|
||||||
/* e_tdev = (major << 24) | (minor & 0xffffff) */
|
/* e_tdev = (major << 24) | (minor & 0xffffff) */
|
||||||
/* e_tdev == -1 for "no device" */
|
/* e_tdev == -1 for "no device" */
|
||||||
proc->tty_nr = ps->kp_eproc.e_tdev & 0xff; /* TODO tty_nr is unsigned */
|
proc->tty_nr = ps->kp_eproc.e_tdev & 0xff; /* TODO tty_nr is unsigned */
|
||||||
|
|
||||||
DarwinProcess_setStartTime(proc, ep, now);
|
DarwinProcess_setStartTime(proc, ep, now);
|
||||||
|
proc->comm = DarwinProcess_getCmdLine(ps, &(proc->basenameOffset));
|
||||||
/* The command is from the old Mac htop */
|
|
||||||
char *slash;
|
|
||||||
|
|
||||||
proc->comm = DarwinProcess_getCmdLine(ps, false);
|
|
||||||
slash = strrchr(proc->comm, '/');
|
|
||||||
proc->basenameOffset = (NULL != slash) ? (slash - proc->comm) : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mutable information */
|
/* Mutable information */
|
||||||
proc->nice = ep->p_nice;
|
proc->nice = ep->p_nice;
|
||||||
proc->priority = ep->p_priority;
|
proc->priority = ep->p_priority;
|
||||||
|
|
||||||
/* Set the state */
|
proc->state = (ep->p_stat == SZOMB) ? 'Z' : '?';
|
||||||
switch(ep->p_stat) {
|
|
||||||
case SIDL: proc->state = 'I'; break;
|
|
||||||
case SRUN: proc->state = 'R'; break;
|
|
||||||
case SSLEEP: proc->state = 'S'; break;
|
|
||||||
case SSTOP: proc->state = 'T'; break;
|
|
||||||
case SZOMB: proc->state = 'Z'; break;
|
|
||||||
default: proc->state = '?'; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure the updated flag is set */
|
/* Make sure the updated flag is set */
|
||||||
proc->updated = true;
|
proc->updated = true;
|
||||||
@ -327,8 +276,8 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
|
|||||||
|
|
||||||
proc->super.time = (pti.pti_total_system + pti.pti_total_user) / 10000000;
|
proc->super.time = (pti.pti_total_system + pti.pti_total_user) / 10000000;
|
||||||
proc->super.nlwp = pti.pti_threadnum;
|
proc->super.nlwp = pti.pti_threadnum;
|
||||||
proc->super.m_size = pti.pti_virtual_size / 1024;
|
proc->super.m_size = pti.pti_virtual_size / 1024 / PAGE_SIZE_KB;
|
||||||
proc->super.m_resident = pti.pti_resident_size / 1024;
|
proc->super.m_resident = pti.pti_resident_size / 1024 / PAGE_SIZE_KB;
|
||||||
proc->super.majflt = pti.pti_faults;
|
proc->super.majflt = pti.pti_faults;
|
||||||
proc->super.percent_mem = (double)pti.pti_resident_size * 100.0
|
proc->super.percent_mem = (double)pti.pti_resident_size * 100.0
|
||||||
/ (double)dpl->host_info.max_mem;
|
/ (double)dpl->host_info.max_mem;
|
||||||
@ -342,3 +291,64 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList
|
|||||||
dpl->super.runningTasks += pti.pti_numrunning;
|
dpl->super.runningTasks += pti.pti_numrunning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan threads for process state information.
|
||||||
|
* Based on: http://stackoverflow.com/questions/6788274/ios-mac-cpu-usage-for-thread
|
||||||
|
* and https://github.com/max-horvath/htop-osx/blob/e86692e869e30b0bc7264b3675d2a4014866ef46/ProcessList.c
|
||||||
|
*/
|
||||||
|
void DarwinProcess_scanThreads(DarwinProcess *dp) {
|
||||||
|
Process* proc = (Process*) dp;
|
||||||
|
kern_return_t ret;
|
||||||
|
|
||||||
|
if (proc->state == 'Z') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
task_t port;
|
||||||
|
ret = task_for_pid(mach_task_self(), proc->pid, &port);
|
||||||
|
if (ret != KERN_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
task_info_data_t tinfo;
|
||||||
|
mach_msg_type_number_t task_info_count = TASK_INFO_MAX;
|
||||||
|
ret = task_info(port, TASK_BASIC_INFO, (task_info_t) tinfo, &task_info_count);
|
||||||
|
if (ret != KERN_SUCCESS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
thread_array_t thread_list;
|
||||||
|
mach_msg_type_number_t thread_count;
|
||||||
|
ret = task_threads(port, &thread_list, &thread_count);
|
||||||
|
if (ret != KERN_SUCCESS) {
|
||||||
|
mach_port_deallocate(mach_task_self(), port);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
integer_t run_state = 999;
|
||||||
|
for (unsigned int i = 0; i < thread_count; i++) {
|
||||||
|
thread_info_data_t thinfo;
|
||||||
|
mach_msg_type_number_t thread_info_count = THREAD_BASIC_INFO_COUNT;
|
||||||
|
ret = thread_info(thread_list[i], THREAD_BASIC_INFO, (thread_info_t)thinfo, &thread_info_count);
|
||||||
|
if (ret == KERN_SUCCESS) {
|
||||||
|
thread_basic_info_t basic_info_th = (thread_basic_info_t) thinfo;
|
||||||
|
if (basic_info_th->run_state < run_state) {
|
||||||
|
run_state = basic_info_th->run_state;
|
||||||
|
}
|
||||||
|
mach_port_deallocate(mach_task_self(), thread_list[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vm_deallocate(mach_task_self(), (vm_address_t) thread_list, sizeof(thread_port_array_t) * thread_count);
|
||||||
|
mach_port_deallocate(mach_task_self(), port);
|
||||||
|
|
||||||
|
char state = '?';
|
||||||
|
switch (run_state) {
|
||||||
|
case TH_STATE_RUNNING: state = 'R'; break;
|
||||||
|
case TH_STATE_STOPPED: state = 'S'; break;
|
||||||
|
case TH_STATE_WAITING: state = 'W'; break;
|
||||||
|
case TH_STATE_UNINTERRUPTIBLE: state = 'U'; break;
|
||||||
|
case TH_STATE_HALTED: state = 'H'; break;
|
||||||
|
}
|
||||||
|
proc->state = state;
|
||||||
|
}
|
||||||
|
@ -32,10 +32,17 @@ bool Process_isThread(Process* this);
|
|||||||
|
|
||||||
void DarwinProcess_setStartTime(Process *proc, struct extern_proc *ep, time_t now);
|
void DarwinProcess_setStartTime(Process *proc, struct extern_proc *ep, time_t now);
|
||||||
|
|
||||||
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int show_args );
|
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset);
|
||||||
|
|
||||||
void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, time_t now, bool exists);
|
void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, time_t now, bool exists);
|
||||||
|
|
||||||
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList *dpl);
|
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess *proc, DarwinProcessList *dpl);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scan threads for process state information.
|
||||||
|
* Based on: http://stackoverflow.com/questions/6788274/ios-mac-cpu-usage-for-thread
|
||||||
|
* and https://github.com/max-horvath/htop-osx/blob/e86692e869e30b0bc7264b3675d2a4014866ef46/ProcessList.c
|
||||||
|
*/
|
||||||
|
void DarwinProcess_scanThreads(DarwinProcess *dp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,8 +168,10 @@ void ProcessList_goThroughEntries(ProcessList* super) {
|
|||||||
for(size_t i = 0; i < count; ++i) {
|
for(size_t i = 0; i < count; ++i) {
|
||||||
proc = (DarwinProcess *)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, (Process_New)DarwinProcess_new);
|
proc = (DarwinProcess *)ProcessList_getProcess(super, ps[i].kp_proc.p_pid, &preExisting, (Process_New)DarwinProcess_new);
|
||||||
|
|
||||||
DarwinProcess_setFromKInfoProc(&proc->super, ps + i, tv.tv_sec, preExisting);
|
DarwinProcess_setFromKInfoProc(&proc->super, &ps[i], tv.tv_sec, preExisting);
|
||||||
DarwinProcess_setFromLibprocPidinfo(proc, dpl);
|
DarwinProcess_setFromLibprocPidinfo(proc, dpl);
|
||||||
|
|
||||||
|
DarwinProcess_scanThreads(proc);
|
||||||
|
|
||||||
super->totalTasks += 1;
|
super->totalTasks += 1;
|
||||||
|
|
||||||
|
@ -6,10 +6,20 @@ in the source distribution for its full text.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
void Battery_getData(double* level, ACPresence* isOnAC) {
|
void Battery_getData(double* level, ACPresence* isOnAC) {
|
||||||
// TODO
|
int life;
|
||||||
*level = -1;
|
size_t life_len = sizeof(life);
|
||||||
*isOnAC = AC_ERROR;
|
if (sysctlbyname("hw.acpi.battery.life", &life, &life_len, NULL, 0) == -1)
|
||||||
}
|
*level = -1;
|
||||||
|
else
|
||||||
|
*level = life;
|
||||||
|
|
||||||
|
int acline;
|
||||||
|
size_t acline_len = sizeof(acline);
|
||||||
|
if (sysctlbyname("hw.acpi.acline", &acline, &acline_len, NULL, 0) == -1)
|
||||||
|
*isOnAC = AC_ERROR;
|
||||||
|
else
|
||||||
|
*isOnAC = acline == 0 ? AC_ABSENT : AC_PRESENT;
|
||||||
|
}
|
||||||
|
@ -11,5 +11,4 @@ in the source distribution for its full text.
|
|||||||
|
|
||||||
void Battery_getData(double* level, ACPresence* isOnAC);
|
void Battery_getData(double* level, ACPresence* isOnAC);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -115,7 +115,7 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
|||||||
char buffer[256]; buffer[255] = '\0';
|
char buffer[256]; buffer[255] = '\0';
|
||||||
int attr = CRT_colors[DEFAULT_COLOR];
|
int attr = CRT_colors[DEFAULT_COLOR];
|
||||||
int n = sizeof(buffer) - 1;
|
int n = sizeof(buffer) - 1;
|
||||||
switch (field) {
|
switch ((int) field) {
|
||||||
// add FreeBSD-specific fields here
|
// add FreeBSD-specific fields here
|
||||||
case JID: snprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
case JID: snprintf(buffer, n, Process_pidFormat, fp->jid); break;
|
||||||
case JAIL:{
|
case JAIL:{
|
||||||
@ -143,7 +143,7 @@ long FreeBSDProcess_compare(const void* v1, const void* v2) {
|
|||||||
p2 = (FreeBSDProcess*)v1;
|
p2 = (FreeBSDProcess*)v1;
|
||||||
p1 = (FreeBSDProcess*)v2;
|
p1 = (FreeBSDProcess*)v2;
|
||||||
}
|
}
|
||||||
switch (settings->sortKey) {
|
switch ((int) settings->sortKey) {
|
||||||
// add FreeBSD-specific fields here
|
// add FreeBSD-specific fields here
|
||||||
case JID:
|
case JID:
|
||||||
return (p1->jid - p2->jid);
|
return (p1->jid - p2->jid);
|
||||||
|
@ -14,7 +14,9 @@ in the source distribution for its full text.
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
#include <err.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
@ -84,14 +86,13 @@ static int MIB_kern_cp_time[2];
|
|||||||
static int MIB_kern_cp_times[2];
|
static int MIB_kern_cp_times[2];
|
||||||
static int kernelFScale;
|
static int kernelFScale;
|
||||||
|
|
||||||
|
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
||||||
|
size_t len;
|
||||||
|
char errbuf[_POSIX2_LINE_MAX];
|
||||||
FreeBSDProcessList* fpl = xCalloc(1, sizeof(FreeBSDProcessList));
|
FreeBSDProcessList* fpl = xCalloc(1, sizeof(FreeBSDProcessList));
|
||||||
ProcessList* pl = (ProcessList*) fpl;
|
ProcessList* pl = (ProcessList*) fpl;
|
||||||
ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidWhiteList, userId);
|
ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidWhiteList, userId);
|
||||||
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
// physical memory in system: hw.physmem
|
// physical memory in system: hw.physmem
|
||||||
// physical page size: hw.pagesize
|
// physical page size: hw.pagesize
|
||||||
// usable pagesize : vm.stats.vm.v_page_size
|
// usable pagesize : vm.stats.vm.v_page_size
|
||||||
@ -178,8 +179,10 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
|||||||
kernelFScale = 2048;
|
kernelFScale = 2048;
|
||||||
}
|
}
|
||||||
|
|
||||||
fpl->kd = kvm_open(NULL, "/dev/null", NULL, 0, NULL);
|
fpl->kd = kvm_openfiles(NULL, "/dev/null", NULL, 0, errbuf);
|
||||||
assert(fpl->kd);
|
if (fpl->kd == NULL) {
|
||||||
|
errx(1, "kvm_open: %s", errbuf);
|
||||||
|
}
|
||||||
|
|
||||||
return pl;
|
return pl;
|
||||||
}
|
}
|
||||||
@ -212,9 +215,6 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||||||
unsigned long *cp_time_n; // old clicks state
|
unsigned long *cp_time_n; // old clicks state
|
||||||
unsigned long *cp_time_o; // current clicks state
|
unsigned long *cp_time_o; // current clicks state
|
||||||
|
|
||||||
unsigned long long total_o = 0;
|
|
||||||
unsigned long long total_n = 0;
|
|
||||||
unsigned long long total_d = 0;
|
|
||||||
unsigned long cp_time_d[CPUSTATES];
|
unsigned long cp_time_d[CPUSTATES];
|
||||||
double cp_time_p[CPUSTATES];
|
double cp_time_p[CPUSTATES];
|
||||||
|
|
||||||
@ -251,6 +251,9 @@ static inline void FreeBSDProcessList_scanCPUTime(ProcessList* pl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// diff old vs new
|
// diff old vs new
|
||||||
|
unsigned long long total_o = 0;
|
||||||
|
unsigned long long total_n = 0;
|
||||||
|
unsigned long long total_d = 0;
|
||||||
for (int s = 0; s < CPUSTATES; s++) {
|
for (int s = 0; s < CPUSTATES; s++) {
|
||||||
cp_time_d[s] = cp_time_n[s] - cp_time_o[s];
|
cp_time_d[s] = cp_time_n[s] - cp_time_o[s];
|
||||||
total_o += cp_time_o[s];
|
total_o += cp_time_o[s];
|
||||||
@ -477,19 +480,19 @@ void ProcessList_goThroughEntries(ProcessList* this) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// from FreeBSD source /src/usr.bin/top/machine.c
|
// from FreeBSD source /src/usr.bin/top/machine.c
|
||||||
proc->m_size = kproc->ki_size / 1024;
|
proc->m_size = kproc->ki_size / 1024 / pageSizeKb;
|
||||||
proc->m_resident = kproc->ki_rssize * pageSizeKb;
|
proc->m_resident = kproc->ki_rssize;
|
||||||
|
proc->percent_mem = (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem) * 100.0;
|
||||||
proc->nlwp = kproc->ki_numthreads;
|
proc->nlwp = kproc->ki_numthreads;
|
||||||
proc->time = (kproc->ki_runtime + 5000) / 10000;
|
proc->time = (kproc->ki_runtime + 5000) / 10000;
|
||||||
|
|
||||||
proc->percent_cpu = 100.0 * ((double)kproc->ki_pctcpu / (double)kernelFScale);
|
proc->percent_cpu = 100.0 * ((double)kproc->ki_pctcpu / (double)kernelFScale);
|
||||||
|
proc->percent_mem = 100.0 * (proc->m_resident * PAGE_SIZE_KB) / (double)(this->totalMem);
|
||||||
|
|
||||||
if (proc->percent_cpu > 0.1) {
|
if (proc->percent_cpu > 0.1) {
|
||||||
// system idle process should own all CPU time left regardless of CPU count
|
// system idle process should own all CPU time left regardless of CPU count
|
||||||
if ( strcmp("idle", kproc->ki_comm) == 0 ) {
|
if ( strcmp("idle", kproc->ki_comm) == 0 ) {
|
||||||
isIdleProcess = true;
|
isIdleProcess = true;
|
||||||
} else {
|
|
||||||
if (cpus > 1)
|
|
||||||
proc->percent_cpu = proc->percent_cpu / (double) cpus;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isIdleProcess == false && proc->percent_cpu >= 99.8) {
|
if (isIdleProcess == false && proc->percent_cpu >= 99.8) {
|
||||||
|
@ -55,7 +55,6 @@ typedef struct FreeBSDProcessList_ {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
|
||||||
|
|
||||||
void ProcessList_delete(ProcessList* this);
|
void ProcessList_delete(ProcessList* this);
|
||||||
|
@ -24,6 +24,7 @@ in the source distribution for its full text.
|
|||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <vm/vm_param.h>
|
#include <vm/vm_param.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
@ -162,15 +163,15 @@ double Platform_setCPUValues(Meter* this, int cpu) {
|
|||||||
double percent;
|
double percent;
|
||||||
double* v = this->values;
|
double* v = this->values;
|
||||||
|
|
||||||
v[CPU_METER_NICE] = cpuData->nicePercent;
|
v[CPU_METER_NICE] = cpuData->nicePercent * cpus;
|
||||||
v[CPU_METER_NORMAL] = cpuData->userPercent;
|
v[CPU_METER_NORMAL] = cpuData->userPercent * cpus;
|
||||||
if (this->pl->settings->detailedCPUTime) {
|
if (this->pl->settings->detailedCPUTime) {
|
||||||
v[CPU_METER_KERNEL] = cpuData->systemPercent;
|
v[CPU_METER_KERNEL] = cpuData->systemPercent * cpus;
|
||||||
v[CPU_METER_IRQ] = cpuData->irqPercent;
|
v[CPU_METER_IRQ] = cpuData->irqPercent * cpus;
|
||||||
Meter_setItems(this, 4);
|
Meter_setItems(this, 4);
|
||||||
percent = v[0]+v[1]+v[2]+v[3];
|
percent = v[0]+v[1]+v[2]+v[3];
|
||||||
} else {
|
} else {
|
||||||
v[2] = cpuData->systemAllPercent;
|
v[2] = cpuData->systemAllPercent * cpus;
|
||||||
Meter_setItems(this, 3);
|
Meter_setItems(this, 3);
|
||||||
percent = v[0]+v[1]+v[2];
|
percent = v[0]+v[1]+v[2];
|
||||||
}
|
}
|
||||||
|
196
htop.c
196
htop.c
@ -176,7 +176,8 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
#ifdef HAVE_PROC
|
#ifdef HAVE_PROC
|
||||||
if (access(PROCDIR, R_OK) != 0) {
|
if (access(PROCDIR, R_OK) != 0) {
|
||||||
fprintf("Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
|
fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -229,194 +230,6 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
ScreenManager_run(scr, NULL, NULL);
|
ScreenManager_run(scr, NULL, NULL);
|
||||||
|
|
||||||
/*
|
|
||||||
FunctionBar_draw(defaultBar, NULL);
|
|
||||||
|
|
||||||
int acc = 0;
|
|
||||||
bool follow = false;
|
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
double oldTime = 0.0;
|
|
||||||
|
|
||||||
int ch = ERR;
|
|
||||||
int closeTimeout = 0;
|
|
||||||
|
|
||||||
bool drawPanel = true;
|
|
||||||
|
|
||||||
bool collapsed = false;
|
|
||||||
|
|
||||||
Htop_Action keys[KEY_MAX] = { NULL };
|
|
||||||
setBindings(keys);
|
|
||||||
Platform_setBindings(keys);
|
|
||||||
|
|
||||||
bool quit = false;
|
|
||||||
int sortTimeout = 0;
|
|
||||||
int resetSortTimeout = 5;
|
|
||||||
bool doRefresh = true;
|
|
||||||
bool forceRecalculate = false;
|
|
||||||
|
|
||||||
while (!quit) {
|
|
||||||
gettimeofday(&tv, NULL);
|
|
||||||
double newTime = ((double)tv.tv_sec * 10) + ((double)tv.tv_usec / 100000);
|
|
||||||
bool timeToRecalculate = (newTime - oldTime > settings->delay);
|
|
||||||
if (newTime < oldTime) timeToRecalculate = true; // clock was adjusted?
|
|
||||||
int following = follow ? MainPanel_selectedPid((MainPanel*)panel) : -1;
|
|
||||||
if (timeToRecalculate) {
|
|
||||||
Header_draw(header);
|
|
||||||
oldTime = newTime;
|
|
||||||
}
|
|
||||||
if (doRefresh) {
|
|
||||||
if (timeToRecalculate || forceRecalculate) {
|
|
||||||
ProcessList_scan(pl);
|
|
||||||
forceRecalculate = false;
|
|
||||||
}
|
|
||||||
if (sortTimeout == 0 || settings->treeView) {
|
|
||||||
ProcessList_sort(pl);
|
|
||||||
sortTimeout = 1;
|
|
||||||
}
|
|
||||||
ProcessList_rebuildPanel(pl, true, following, IncSet_filter(inc));
|
|
||||||
drawPanel = true;
|
|
||||||
}
|
|
||||||
doRefresh = true;
|
|
||||||
|
|
||||||
if (settings->treeView) {
|
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
|
||||||
if (p) {
|
|
||||||
if (!p->showChildren && !collapsed) {
|
|
||||||
FunctionBar_setLabel(defaultBar, KEY_F(6), "Expand");
|
|
||||||
FunctionBar_draw(defaultBar, NULL);
|
|
||||||
} else if (p->showChildren && collapsed) {
|
|
||||||
FunctionBar_setLabel(defaultBar, KEY_F(6), "Collap");
|
|
||||||
FunctionBar_draw(defaultBar, NULL);
|
|
||||||
}
|
|
||||||
collapsed = !p->showChildren;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
collapsed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drawPanel) {
|
|
||||||
Panel_draw(panel, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
int prev = ch;
|
|
||||||
if (inc->active)
|
|
||||||
move(LINES-1, CRT_cursorX);
|
|
||||||
ch = getch();
|
|
||||||
|
|
||||||
if (ch == ERR) {
|
|
||||||
if (!inc->active)
|
|
||||||
sortTimeout--;
|
|
||||||
if (prev == ch && !timeToRecalculate) {
|
|
||||||
closeTimeout++;
|
|
||||||
if (closeTimeout == 100) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
closeTimeout = 0;
|
|
||||||
drawPanel = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
drawPanel = true;
|
|
||||||
|
|
||||||
Htop_Reaction reaction = HTOP_OK;
|
|
||||||
|
|
||||||
if (ch == KEY_MOUSE) {
|
|
||||||
MEVENT mevent;
|
|
||||||
int ok = getmouse(&mevent);
|
|
||||||
if (ok == OK) {
|
|
||||||
if (mevent.bstate & BUTTON1_CLICKED) {
|
|
||||||
if (mevent.y == panel->y) {
|
|
||||||
int x = panel->scrollH + mevent.x + 1;
|
|
||||||
ProcessField field = ProcessList_keyAt(pl, x);
|
|
||||||
if (field == settings->sortKey) {
|
|
||||||
Settings_invertSortOrder(settings);
|
|
||||||
settings->treeView = false;
|
|
||||||
reaction |= HTOP_REDRAW_BAR;
|
|
||||||
} else {
|
|
||||||
reaction |= setSortKey(settings, field);
|
|
||||||
}
|
|
||||||
sortTimeout = 0;
|
|
||||||
ch = ERR;
|
|
||||||
} else if (mevent.y >= panel->y + 1 && mevent.y < LINES - 1) {
|
|
||||||
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
|
|
||||||
follow = true;
|
|
||||||
ch = ERR;
|
|
||||||
} if (mevent.y == LINES - 1) {
|
|
||||||
ch = FunctionBar_synthesizeEvent(inc->bar, mevent.x);
|
|
||||||
}
|
|
||||||
} else if (mevent.bstate & BUTTON4_CLICKED) {
|
|
||||||
ch = KEY_UP;
|
|
||||||
#if NCURSES_MOUSE_VERSION > 1
|
|
||||||
} else if (mevent.bstate & BUTTON5_CLICKED) {
|
|
||||||
ch = KEY_DOWN;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inc->active) {
|
|
||||||
doRefresh = IncSet_handleKey(inc, ch, panel, getMainPanelValue, NULL);
|
|
||||||
if (!inc->active) {
|
|
||||||
follow = true;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ch < 255 && isdigit((char)ch)) {
|
|
||||||
if (Panel_size(panel) == 0) continue;
|
|
||||||
pid_t pid = ch-48 + acc;
|
|
||||||
for (int i = 0; i < ProcessList_size(pl); i++) {
|
|
||||||
Panel_setSelected(panel, i);
|
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
|
||||||
if (p && p->pid == pid) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
acc = pid * 10;
|
|
||||||
if (acc > 10000000)
|
|
||||||
acc = 0;
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
acc = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ch != ERR && keys[ch]) {
|
|
||||||
reaction |= (keys[ch])(&state);
|
|
||||||
} else {
|
|
||||||
doRefresh = false;
|
|
||||||
sortTimeout = resetSortTimeout;
|
|
||||||
Panel_onKey(panel, ch);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reaction handlers:
|
|
||||||
|
|
||||||
if (reaction & HTOP_REDRAW_BAR) {
|
|
||||||
updateTreeFunctions(defaultBar, settings->treeView);
|
|
||||||
IncSet_drawBar(inc);
|
|
||||||
}
|
|
||||||
if (reaction & HTOP_UPDATE_PANELHDR) {
|
|
||||||
ProcessList_printHeader(pl, Panel_getHeader(panel));
|
|
||||||
}
|
|
||||||
if (reaction & HTOP_REFRESH) {
|
|
||||||
doRefresh = true;
|
|
||||||
sortTimeout = 0;
|
|
||||||
}
|
|
||||||
if (reaction & HTOP_RECALCULATE) {
|
|
||||||
forceRecalculate = true;
|
|
||||||
sortTimeout = 0;
|
|
||||||
}
|
|
||||||
if (reaction & HTOP_SAVE_SETTINGS) {
|
|
||||||
settings->changed = true;
|
|
||||||
}
|
|
||||||
if (reaction & HTOP_QUIT) {
|
|
||||||
quit = true;
|
|
||||||
}
|
|
||||||
follow = (reaction & HTOP_KEEP_FOLLOWING);
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
attron(CRT_colors[RESET_COLOR]);
|
attron(CRT_colors[RESET_COLOR]);
|
||||||
mvhline(LINES-1, 0, ' ', COLS);
|
mvhline(LINES-1, 0, ' ', COLS);
|
||||||
attroff(CRT_colors[RESET_COLOR]);
|
attroff(CRT_colors[RESET_COLOR]);
|
||||||
@ -428,11 +241,6 @@ int main(int argc, char** argv) {
|
|||||||
Header_delete(header);
|
Header_delete(header);
|
||||||
ProcessList_delete(pl);
|
ProcessList_delete(pl);
|
||||||
|
|
||||||
/*
|
|
||||||
FunctionBar_delete((Object*)defaultBar);
|
|
||||||
Panel_delete((Object*)panel);
|
|
||||||
*/
|
|
||||||
|
|
||||||
ScreenManager_delete(scr);
|
ScreenManager_delete(scr);
|
||||||
|
|
||||||
UsersTable_delete(ut);
|
UsersTable_delete(ut);
|
||||||
|
@ -268,13 +268,20 @@ io_priority = (cpu_nice + 20) / 5. -- From ionice(1) man page
|
|||||||
#define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority)
|
#define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority)
|
||||||
|
|
||||||
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) {
|
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this) {
|
||||||
IOPriority ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->super.pid);
|
IOPriority ioprio = 0;
|
||||||
|
// Other OSes masquerading as Linux (NetBSD?) don't have this syscall
|
||||||
|
#ifdef SYS_ioprio_get
|
||||||
|
ioprio = syscall(SYS_ioprio_get, IOPRIO_WHO_PROCESS, this->super.pid);
|
||||||
|
#endif
|
||||||
this->ioPriority = ioprio;
|
this->ioPriority = ioprio;
|
||||||
return ioprio;
|
return ioprio;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) {
|
bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio) {
|
||||||
|
// Other OSes masquerading as Linux (NetBSD?) don't have this syscall
|
||||||
|
#ifdef SYS_ioprio_set
|
||||||
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio);
|
syscall(SYS_ioprio_set, IOPRIO_WHO_PROCESS, this->super.pid, ioprio);
|
||||||
|
#endif
|
||||||
return (LinuxProcess_updateIOPriority(this) == ioprio);
|
return (LinuxProcess_updateIOPriority(this) == ioprio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +313,12 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
|
|||||||
case CNCLWB: Process_colorNumber(str, lp->io_cancelled_write_bytes, coloring); return;
|
case CNCLWB: Process_colorNumber(str, lp->io_cancelled_write_bytes, coloring); return;
|
||||||
case IO_READ_RATE: Process_outputRate(str, buffer, n, lp->io_rate_read_bps, coloring); return;
|
case IO_READ_RATE: Process_outputRate(str, buffer, n, lp->io_rate_read_bps, coloring); return;
|
||||||
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
|
case IO_WRITE_RATE: Process_outputRate(str, buffer, n, lp->io_rate_write_bps, coloring); return;
|
||||||
case IO_RATE: Process_outputRate(str, buffer, n, lp->io_rate_read_bps + lp->io_rate_write_bps, coloring); return;
|
case IO_RATE: {
|
||||||
|
double totalRate = (lp->io_rate_read_bps != -1)
|
||||||
|
? (lp->io_rate_read_bps + lp->io_rate_write_bps)
|
||||||
|
: -1;
|
||||||
|
Process_outputRate(str, buffer, n, totalRate, coloring); return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OPENVZ
|
#ifdef HAVE_OPENVZ
|
||||||
case CTID: snprintf(buffer, n, "%7u ", lp->ctid); break;
|
case CTID: snprintf(buffer, n, "%7u ", lp->ctid); break;
|
||||||
|
@ -292,15 +292,16 @@ static void LinuxProcessList_readIoFile(LinuxProcess* process, const char* dirna
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (line[5] == 'r' && strncmp(line+1, "yscr: ", 6) == 0)
|
if (line[5] == 'r' && strncmp(line+1, "yscr: ", 6) == 0) {
|
||||||
process->io_syscr = strtoull(line+7, NULL, 10);
|
process->io_syscr = strtoull(line+7, NULL, 10);
|
||||||
else if (strncmp(line+1, "yscw: ", 6) == 0)
|
} else if (strncmp(line+1, "yscw: ", 6) == 0) {
|
||||||
sscanf(line, "syscw: %32llu", &process->io_syscw);
|
|
||||||
process->io_syscw = strtoull(line+7, NULL, 10);
|
process->io_syscw = strtoull(line+7, NULL, 10);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
if (strncmp(line+1, "ancelled_write_bytes: ", 22) == 0)
|
if (strncmp(line+1, "ancelled_write_bytes: ", 22) == 0) {
|
||||||
process->io_cancelled_write_bytes = strtoull(line+23, NULL, 10);
|
process->io_cancelled_write_bytes = strtoull(line+23, NULL, 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,7 +447,7 @@ static void LinuxProcessList_readOomData(LinuxProcess* process, const char* dirn
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void setCommand(Process* process, const char* command, int len) {
|
static void setCommand(Process* process, const char* command, int len) {
|
||||||
if (process->comm && process->commLen <= len) {
|
if (process->comm && process->commLen >= len) {
|
||||||
strncpy(process->comm, command, len + 1);
|
strncpy(process->comm, command, len + 1);
|
||||||
} else {
|
} else {
|
||||||
free(process->comm);
|
free(process->comm);
|
||||||
@ -584,7 +585,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
|||||||
|
|
||||||
ProcessList_add(pl, proc);
|
ProcessList_add(pl, proc);
|
||||||
} else {
|
} else {
|
||||||
if (settings->updateProcessNames) {
|
if (settings->updateProcessNames && proc->state != 'Z') {
|
||||||
if (! LinuxProcessList_readCmdlineFile(proc, dirname, name)) {
|
if (! LinuxProcessList_readCmdlineFile(proc, dirname, name)) {
|
||||||
goto errorReadingProcess;
|
goto errorReadingProcess;
|
||||||
}
|
}
|
||||||
@ -599,11 +600,11 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
|||||||
if (settings->flags & PROCESS_FLAG_LINUX_OOM)
|
if (settings->flags & PROCESS_FLAG_LINUX_OOM)
|
||||||
LinuxProcessList_readOomData(lp, dirname, name);
|
LinuxProcessList_readOomData(lp, dirname, name);
|
||||||
|
|
||||||
if (proc->state == 'Z') {
|
if (proc->state == 'Z' && (proc->basenameOffset == 0)) {
|
||||||
proc->basenameOffset = -1;
|
proc->basenameOffset = -1;
|
||||||
setCommand(proc, command, commLen);
|
setCommand(proc, command, commLen);
|
||||||
} else if (Process_isThread(proc)) {
|
} else if (Process_isThread(proc)) {
|
||||||
if (settings->showThreadNames || Process_isKernelThread(proc) || proc->state == 'Z') {
|
if (settings->showThreadNames || Process_isKernelThread(proc) || (proc->state == 'Z' && proc->basenameOffset == 0)) {
|
||||||
proc->basenameOffset = -1;
|
proc->basenameOffset = -1;
|
||||||
setCommand(proc, command, commLen);
|
setCommand(proc, command, commLen);
|
||||||
} else if (settings->showThreadNames) {
|
} else if (settings->showThreadNames) {
|
||||||
@ -720,31 +721,23 @@ static inline double LinuxProcessList_scanCPUTime(LinuxProcessList* this) {
|
|||||||
unsigned long long int virtalltime = guest + guestnice;
|
unsigned long long int virtalltime = guest + guestnice;
|
||||||
unsigned long long int totaltime = usertime + nicetime + systemalltime + idlealltime + steal + virtalltime;
|
unsigned long long int totaltime = usertime + nicetime + systemalltime + idlealltime + steal + virtalltime;
|
||||||
CPUData* cpuData = &(this->cpus[i]);
|
CPUData* cpuData = &(this->cpus[i]);
|
||||||
assert (systemtime >= cpuData->systemTime);
|
|
||||||
assert (idletime >= cpuData->idleTime);
|
|
||||||
assert (totaltime >= cpuData->totalTime);
|
|
||||||
assert (systemalltime >= cpuData->systemAllTime);
|
|
||||||
assert (idlealltime >= cpuData->idleAllTime);
|
|
||||||
assert (ioWait >= cpuData->ioWaitTime);
|
|
||||||
assert (irq >= cpuData->irqTime);
|
|
||||||
assert (softIrq >= cpuData->softIrqTime);
|
|
||||||
assert (steal >= cpuData->stealTime);
|
|
||||||
assert (virtalltime >= cpuData->guestTime);
|
|
||||||
// Since we do a subtraction (usertime - guest) and cputime64_to_clock_t()
|
// Since we do a subtraction (usertime - guest) and cputime64_to_clock_t()
|
||||||
// used in /proc/stat rounds down numbers, it can lead to a case where the
|
// used in /proc/stat rounds down numbers, it can lead to a case where the
|
||||||
// integer overflow.
|
// integer overflow.
|
||||||
cpuData->userPeriod = (usertime > cpuData->userTime) ? usertime - cpuData->userTime : 0;
|
#define WRAP_SUBTRACT(a,b) (a > b) ? a - b : 0
|
||||||
cpuData->nicePeriod = (nicetime > cpuData->niceTime) ? nicetime - cpuData->niceTime : 0;
|
cpuData->userPeriod = WRAP_SUBTRACT(usertime, cpuData->userTime);
|
||||||
cpuData->systemPeriod = systemtime - cpuData->systemTime;
|
cpuData->nicePeriod = WRAP_SUBTRACT(nicetime, cpuData->niceTime);
|
||||||
cpuData->systemAllPeriod = systemalltime - cpuData->systemAllTime;
|
cpuData->systemPeriod = WRAP_SUBTRACT(systemtime, cpuData->systemTime);
|
||||||
cpuData->idleAllPeriod = idlealltime - cpuData->idleAllTime;
|
cpuData->systemAllPeriod = WRAP_SUBTRACT(systemalltime, cpuData->systemAllTime);
|
||||||
cpuData->idlePeriod = idletime - cpuData->idleTime;
|
cpuData->idleAllPeriod = WRAP_SUBTRACT(idlealltime, cpuData->idleAllTime);
|
||||||
cpuData->ioWaitPeriod = ioWait - cpuData->ioWaitTime;
|
cpuData->idlePeriod = WRAP_SUBTRACT(idletime, cpuData->idleTime);
|
||||||
cpuData->irqPeriod = irq - cpuData->irqTime;
|
cpuData->ioWaitPeriod = WRAP_SUBTRACT(ioWait, cpuData->ioWaitTime);
|
||||||
cpuData->softIrqPeriod = softIrq - cpuData->softIrqTime;
|
cpuData->irqPeriod = WRAP_SUBTRACT(irq, cpuData->irqTime);
|
||||||
cpuData->stealPeriod = steal - cpuData->stealTime;
|
cpuData->softIrqPeriod = WRAP_SUBTRACT(softIrq, cpuData->softIrqTime);
|
||||||
cpuData->guestPeriod = virtalltime - cpuData->guestTime;
|
cpuData->stealPeriod = WRAP_SUBTRACT(steal, cpuData->stealTime);
|
||||||
cpuData->totalPeriod = totaltime - cpuData->totalTime;
|
cpuData->guestPeriod = WRAP_SUBTRACT(virtalltime, cpuData->guestTime);
|
||||||
|
cpuData->totalPeriod = WRAP_SUBTRACT(totaltime, cpuData->totalTime);
|
||||||
|
#undef WRAP_SUBTRACT
|
||||||
cpuData->userTime = usertime;
|
cpuData->userTime = usertime;
|
||||||
cpuData->niceTime = nicetime;
|
cpuData->niceTime = nicetime;
|
||||||
cpuData->systemTime = systemtime;
|
cpuData->systemTime = systemtime;
|
||||||
|
@ -10,18 +10,20 @@ in the source distribution for its full text.
|
|||||||
#include "OpenBSDProcessList.h"
|
#include "OpenBSDProcessList.h"
|
||||||
#include "OpenBSDProcess.h"
|
#include "OpenBSDProcess.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <fcntl.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/sysctl.h>
|
|
||||||
#include <sys/user.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/*{
|
/*{
|
||||||
|
|
||||||
@ -42,22 +44,37 @@ typedef struct OpenBSDProcessList_ {
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
#ifndef CLAMP
|
/*
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
* avoid relying on or conflicting with MIN() and MAX() in sys/param.h
|
||||||
|
*/
|
||||||
|
#ifndef MINIMUM
|
||||||
|
#define MINIMUM(x, y) ((x) > (y) ? (y) : (x))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAXIMUM
|
||||||
|
#define MAXIMUM(x, y) ((x) > (y) ? (x) : (y))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CLAMP
|
||||||
|
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int pageSizeKb;
|
|
||||||
static long fscale;
|
static long fscale;
|
||||||
|
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
||||||
int mib[] = { CTL_HW, HW_NCPU };
|
int mib[] = { CTL_HW, HW_NCPU };
|
||||||
int fmib[] = { CTL_KERN, KERN_FSCALE };
|
int fmib[] = { CTL_KERN, KERN_FSCALE };
|
||||||
int i, e;
|
int i, e;
|
||||||
OpenBSDProcessList* opl = xCalloc(1, sizeof(OpenBSDProcessList));
|
OpenBSDProcessList* opl;
|
||||||
ProcessList* pl = (ProcessList*) opl;
|
ProcessList* pl;
|
||||||
size_t size = sizeof(pl->cpuCount);
|
size_t size;
|
||||||
|
char errbuf[_POSIX2_LINE_MAX];
|
||||||
|
|
||||||
|
opl = xCalloc(1, sizeof(OpenBSDProcessList));
|
||||||
|
pl = (ProcessList*) opl;
|
||||||
|
size = sizeof(pl->cpuCount);
|
||||||
ProcessList_init(pl, Class(OpenBSDProcess), usersTable, pidWhiteList, userId);
|
ProcessList_init(pl, Class(OpenBSDProcess), usersTable, pidWhiteList, userId);
|
||||||
|
|
||||||
e = sysctl(mib, 2, &pl->cpuCount, &size, NULL, 0);
|
e = sysctl(mib, 2, &pl->cpuCount, &size, NULL, 0);
|
||||||
if (e == -1 || pl->cpuCount < 1) {
|
if (e == -1 || pl->cpuCount < 1) {
|
||||||
pl->cpuCount = 1;
|
pl->cpuCount = 1;
|
||||||
@ -65,26 +82,29 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
|||||||
opl->cpus = xRealloc(opl->cpus, pl->cpuCount * sizeof(CPUData));
|
opl->cpus = xRealloc(opl->cpus, pl->cpuCount * sizeof(CPUData));
|
||||||
|
|
||||||
size = sizeof(fscale);
|
size = sizeof(fscale);
|
||||||
if (sysctl(fmib, 2, &fscale, &size, NULL, 0) < 0)
|
if (sysctl(fmib, 2, &fscale, &size, NULL, 0) < 0) {
|
||||||
err(1, "fscale sysctl call failed");
|
err(1, "fscale sysctl call failed");
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < pl->cpuCount; i++) {
|
for (i = 0; i < pl->cpuCount; i++) {
|
||||||
opl->cpus[i].totalTime = 1;
|
opl->cpus[i].totalTime = 1;
|
||||||
opl->cpus[i].totalPeriod = 1;
|
opl->cpus[i].totalPeriod = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pageSizeKb = PAGE_SIZE_KB;
|
opl->kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
|
||||||
|
if (opl->kd == NULL) {
|
||||||
// XXX: last arg should eventually be an errbuf
|
errx(1, "kvm_open: %s", errbuf);
|
||||||
opl->kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL);
|
}
|
||||||
assert(opl->kd);
|
|
||||||
|
|
||||||
return pl;
|
return pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList_delete(ProcessList* this) {
|
void ProcessList_delete(ProcessList* this) {
|
||||||
const OpenBSDProcessList* opl = (OpenBSDProcessList*) this;
|
const OpenBSDProcessList* opl = (OpenBSDProcessList*) this;
|
||||||
if (opl->kd) kvm_close(opl->kd);
|
|
||||||
|
if (opl->kd) {
|
||||||
|
kvm_close(opl->kd);
|
||||||
|
}
|
||||||
|
|
||||||
free(opl->cpus);
|
free(opl->cpus);
|
||||||
|
|
||||||
@ -95,15 +115,26 @@ void ProcessList_delete(ProcessList* this) {
|
|||||||
static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
||||||
static int uvmexp_mib[] = {CTL_VM, VM_UVMEXP};
|
static int uvmexp_mib[] = {CTL_VM, VM_UVMEXP};
|
||||||
struct uvmexp uvmexp;
|
struct uvmexp uvmexp;
|
||||||
size_t size = sizeof(uvmexp);
|
size_t size_uvmexp = sizeof(uvmexp);
|
||||||
|
|
||||||
if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) < 0) {
|
if (sysctl(uvmexp_mib, 2, &uvmexp, &size_uvmexp, NULL, 0) < 0) {
|
||||||
err(1, "uvmexp sysctl call failed");
|
err(1, "uvmexp sysctl call failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
//kb_pagesize = uvmexp.pagesize / 1024;
|
pl->totalMem = uvmexp.npages * PAGE_SIZE_KB;
|
||||||
pl->usedMem = uvmexp.active * pageSizeKb;
|
|
||||||
pl->totalMem = uvmexp.npages * pageSizeKb;
|
// Taken from OpenBSD systat/iostat.c, top/machine.c and uvm_sysctl(9)
|
||||||
|
static int bcache_mib[] = {CTL_VFS, VFS_GENERIC, VFS_BCACHESTAT};
|
||||||
|
struct bcachestats bcstats;
|
||||||
|
size_t size_bcstats = sizeof(bcstats);
|
||||||
|
|
||||||
|
if (sysctl(bcache_mib, 3, &bcstats, &size_bcstats, NULL, 0) < 0) {
|
||||||
|
err(1, "cannot get vfs.bcachestat");
|
||||||
|
}
|
||||||
|
|
||||||
|
pl->cachedMem = bcstats.numbufpages * PAGE_SIZE_KB;
|
||||||
|
pl->freeMem = uvmexp.free * PAGE_SIZE_KB;
|
||||||
|
pl->usedMem = (uvmexp.npages - uvmexp.free - uvmexp.paging) * PAGE_SIZE_KB;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
const OpenBSDProcessList* opl = (OpenBSDProcessList*) pl;
|
const OpenBSDProcessList* opl = (OpenBSDProcessList*) pl;
|
||||||
@ -112,10 +143,10 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||||||
sysctl(MIB_hw_physmem, 2, &(pl->totalMem), &len, NULL, 0);
|
sysctl(MIB_hw_physmem, 2, &(pl->totalMem), &len, NULL, 0);
|
||||||
pl->totalMem /= 1024;
|
pl->totalMem /= 1024;
|
||||||
sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(pl->usedMem), &len, NULL, 0);
|
sysctl(MIB_vm_stats_vm_v_wire_count, 4, &(pl->usedMem), &len, NULL, 0);
|
||||||
pl->usedMem *= pageSizeKb;
|
pl->usedMem *= PAGE_SIZE_KB;
|
||||||
pl->freeMem = pl->totalMem - pl->usedMem;
|
pl->freeMem = pl->totalMem - pl->usedMem;
|
||||||
sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0);
|
sysctl(MIB_vm_stats_vm_v_cache_count, 4, &(pl->cachedMem), &len, NULL, 0);
|
||||||
pl->cachedMem *= pageSizeKb;
|
pl->cachedMem *= PAGE_SIZE_KB;
|
||||||
|
|
||||||
struct kvm_swap swap[16];
|
struct kvm_swap swap[16];
|
||||||
int nswap = kvm_getswapinfo(opl->kd, swap, sizeof(swap)/sizeof(swap[0]), 0);
|
int nswap = kvm_getswapinfo(opl->kd, swap, sizeof(swap)/sizeof(swap[0]), 0);
|
||||||
@ -125,8 +156,8 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||||||
pl->totalSwap += swap[i].ksw_total;
|
pl->totalSwap += swap[i].ksw_total;
|
||||||
pl->usedSwap += swap[i].ksw_used;
|
pl->usedSwap += swap[i].ksw_used;
|
||||||
}
|
}
|
||||||
pl->totalSwap *= pageSizeKb;
|
pl->totalSwap *= PAGE_SIZE_KB;
|
||||||
pl->usedSwap *= pageSizeKb;
|
pl->usedSwap *= PAGE_SIZE_KB;
|
||||||
|
|
||||||
pl->sharedMem = 0; // currently unused
|
pl->sharedMem = 0; // currently unused
|
||||||
pl->buffersMem = 0; // not exposed to userspace
|
pl->buffersMem = 0; // not exposed to userspace
|
||||||
@ -134,40 +165,40 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) {
|
char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) {
|
||||||
char *s, *buf, **arg;
|
char *s, **arg;
|
||||||
size_t cpsz, len = 0, n;
|
size_t len = 0, n;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We attempt to fall back to just the command name (argv[0]) if we
|
* Like OpenBSD's top(1), we try to fall back to the command name
|
||||||
* fail to construct the full command at any point.
|
* (argv[0]) if we fail to construct the full command.
|
||||||
*/
|
*/
|
||||||
arg = kvm_getargv(kd, kproc, 500);
|
arg = kvm_getargv(kd, kproc, 500);
|
||||||
if (arg == NULL) {
|
if (arg == NULL || *arg == NULL) {
|
||||||
if ((s = xStrdup(kproc->p_comm)) == NULL) {
|
*basenameEnd = strlen(kproc->p_comm);
|
||||||
err(1, NULL);
|
return xStrdup(kproc->p_comm);
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
for (i = 0; arg[i] != NULL; i++) {
|
for (i = 0; arg[i] != NULL; i++) {
|
||||||
len += strlen(arg[i]) + 1;
|
len += strlen(arg[i]) + 1; /* room for arg and trailing space or NUL */
|
||||||
}
|
}
|
||||||
if ((buf = s = xMalloc(len)) == NULL) {
|
/* don't use xMalloc here - we want to handle huge argv's gracefully */
|
||||||
if ((s = xStrdup(kproc->p_comm)) == NULL) {
|
if ((s = malloc(len)) == NULL) {
|
||||||
err(1, NULL);
|
*basenameEnd = strlen(kproc->p_comm);
|
||||||
}
|
return xStrdup(kproc->p_comm);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*s = '\0';
|
||||||
|
|
||||||
for (i = 0; arg[i] != NULL; i++) {
|
for (i = 0; arg[i] != NULL; i++) {
|
||||||
n = strlcpy(buf, arg[i], (s + len) - buf);
|
n = strlcat(s, arg[i], len);
|
||||||
buf += n;
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
*basenameEnd = n;
|
/* TODO: rename all basenameEnd to basenameLen, make size_t */
|
||||||
|
*basenameEnd = MINIMUM(n, len-1);
|
||||||
}
|
}
|
||||||
*buf = ' ';
|
/* the trailing space should get truncated anyway */
|
||||||
buf++;
|
strlcat(s, " ", len);
|
||||||
}
|
}
|
||||||
*(buf - 1) = '\0';
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,20 @@ typedef struct OpenBSDProcessList_ {
|
|||||||
} OpenBSDProcessList;
|
} OpenBSDProcessList;
|
||||||
|
|
||||||
|
|
||||||
#ifndef CLAMP
|
/*
|
||||||
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
|
* avoid relying on or conflicting with MIN() and MAX() in sys/param.h
|
||||||
|
*/
|
||||||
|
#ifndef MINIMUM
|
||||||
|
#define MINIMUM(x, y) ((x) > (y) ? (y) : (x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAXIMUM
|
||||||
|
#define MAXIMUM(x, y) ((x) > (y) ? (x) : (y))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CLAMP
|
||||||
|
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : MAXIMUM(x, low))
|
||||||
|
#endif
|
||||||
|
|
||||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
|
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
|
||||||
|
|
||||||
|
146
test_spec.lua
146
test_spec.lua
@ -4,6 +4,8 @@ local VISUALDELAY = os.getenv("VISUALDELAY")
|
|||||||
|
|
||||||
local visual = VISUALDELAY or false
|
local visual = VISUALDELAY or false
|
||||||
local visual_delay = VISUALDELAY and (tonumber(VISUALDELAY)) or 0.1
|
local visual_delay = VISUALDELAY and (tonumber(VISUALDELAY)) or 0.1
|
||||||
|
local short_delay = 0.3
|
||||||
|
local long_delay = 1
|
||||||
|
|
||||||
local unistd = require("posix.unistd")
|
local unistd = require("posix.unistd")
|
||||||
local time = require("posix.time")
|
local time = require("posix.time")
|
||||||
@ -12,15 +14,16 @@ local rote = require("rote")
|
|||||||
|
|
||||||
local rt = rote.RoteTerm(24, 80)
|
local rt = rote.RoteTerm(24, 80)
|
||||||
|
|
||||||
|
--[[
|
||||||
local function os_execread(cmd)
|
local function os_execread(cmd)
|
||||||
local fd = io.popen(cmd, "r")
|
local fd = io.popen(cmd, "r")
|
||||||
local out = fd:read("*a")
|
local out = fd:read("*a")
|
||||||
fd:close()
|
fd:close()
|
||||||
return (out:gsub("\n$", ""))
|
return (out:gsub("\n$", ""))
|
||||||
end
|
end
|
||||||
local branch = os_execread("git branch | grep '*'"):sub(3)
|
]]
|
||||||
|
--local branch = os_execread("git branch | grep '*'"):sub(3)
|
||||||
print("Running in branch "..branch)
|
--print("Running in branch "..branch)
|
||||||
|
|
||||||
os.execute("make coverage")
|
os.execute("make coverage")
|
||||||
os.execute("rm -f *.gcda */*.gcda")
|
os.execute("rm -f *.gcda */*.gcda")
|
||||||
@ -30,7 +33,7 @@ os.execute("killall htop")
|
|||||||
os.execute("ps aux | grep '[s]leep 12345' | awk '{print $2}' | xargs kill 2> /dev/null")
|
os.execute("ps aux | grep '[s]leep 12345' | awk '{print $2}' | xargs kill 2> /dev/null")
|
||||||
|
|
||||||
os.execute("cp ./default.htoprc ./test.htoprc")
|
os.execute("cp ./default.htoprc ./test.htoprc")
|
||||||
rt:forkPty("LC_ALL=C HTOPRC=./test.htoprc ./htop")
|
rt:forkPty("LC_ALL=C HTOPRC=./test.htoprc ./htop 2> htop-valgrind.txt")
|
||||||
|
|
||||||
local stdscr, term_win
|
local stdscr, term_win
|
||||||
-- Curses initalization needed even when not in visual mode
|
-- Curses initalization needed even when not in visual mode
|
||||||
@ -59,10 +62,6 @@ else
|
|||||||
curses.endwin()
|
curses.endwin()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function delay(t)
|
|
||||||
time.nanosleep({ tv_sec = math.floor(t), tv_nsec = (t - math.floor(t)) * 1000000000 })
|
|
||||||
end
|
|
||||||
|
|
||||||
local function show(key)
|
local function show(key)
|
||||||
rt:update()
|
rt:update()
|
||||||
if visual then
|
if visual then
|
||||||
@ -115,7 +114,12 @@ end
|
|||||||
|
|
||||||
local ESC = "\27\27"
|
local ESC = "\27\27"
|
||||||
|
|
||||||
time.nanosleep({ tv_sec = 0, tv_nsec = 150000000 }) -- give some time for htop to initialize.
|
function delay(t)
|
||||||
|
time.nanosleep({ tv_sec = math.floor(t), tv_nsec = (t - math.floor(t)) * 1000000000 })
|
||||||
|
end
|
||||||
|
|
||||||
|
delay(2) -- give some time for htop to initialize.
|
||||||
|
rt:update()
|
||||||
|
|
||||||
local y_panelhdr = (function()
|
local y_panelhdr = (function()
|
||||||
for y = 1, 24 do
|
for y = 1, 24 do
|
||||||
@ -125,7 +129,9 @@ local y_panelhdr = (function()
|
|||||||
end
|
end
|
||||||
end)() or 1
|
end)() or 1
|
||||||
|
|
||||||
local x_metercol2 = (branch == "wip") and 41 or 43
|
assert.not_equal(y_panelhdr, 1)
|
||||||
|
|
||||||
|
local x_metercol2 = 41
|
||||||
|
|
||||||
show()
|
show()
|
||||||
|
|
||||||
@ -190,7 +196,7 @@ describe("htop test suite", function()
|
|||||||
send("\\")
|
send("\\")
|
||||||
send("x\127bux\127sted") -- test backspace
|
send("x\127bux\127sted") -- test backspace
|
||||||
send("\n")
|
send("\n")
|
||||||
delay(0.2)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local pid = (" "..tostring(unistd.getpid())):sub(-5)
|
local pid = (" "..tostring(unistd.getpid())):sub(-5)
|
||||||
local ourpid = check_string_at(1, y_panelhdr + 1, pid)
|
local ourpid = check_string_at(1, y_panelhdr + 1, pid)
|
||||||
@ -198,10 +204,10 @@ describe("htop test suite", function()
|
|||||||
send(ESC)
|
send(ESC)
|
||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
send(curses.KEY_HOME)
|
send(curses.KEY_HOME)
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local initpid = check_string_at(1, y_panelhdr + 1, " 1")
|
local initpid = check_string_at(1, y_panelhdr + 1, " 1")
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
assert.equal(check(ourpid))
|
assert.equal(check(ourpid))
|
||||||
@ -213,7 +219,7 @@ describe("htop test suite", function()
|
|||||||
send("/")
|
send("/")
|
||||||
send("busted")
|
send("busted")
|
||||||
local attr = rt:cellAttr(rt:rows() - 1, 30)
|
local attr = rt:cellAttr(rt:rows() - 1, 30)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
local line = find_selected_y()
|
local line = find_selected_y()
|
||||||
local pid = (" "..tostring(unistd.getpid())):sub(-5)
|
local pid = (" "..tostring(unistd.getpid())):sub(-5)
|
||||||
assert.equal(attr, attrs.black_on_cyan)
|
assert.equal(attr, attrs.black_on_cyan)
|
||||||
@ -227,7 +233,7 @@ describe("htop test suite", function()
|
|||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
send(curses.KEY_END)
|
send(curses.KEY_END)
|
||||||
send("1")
|
send("1")
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
local line = find_selected_y()
|
local line = find_selected_y()
|
||||||
local initpid = check_string_at(1, line, " 1")
|
local initpid = check_string_at(1, line, " 1")
|
||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
@ -238,16 +244,16 @@ describe("htop test suite", function()
|
|||||||
running_it("horizontal scroll", function()
|
running_it("horizontal scroll", function()
|
||||||
local h_scroll = 20
|
local h_scroll = 20
|
||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
local str1 = string_at(1+h_scroll, y_panelhdr+1, 5)
|
local str1 = string_at(1+h_scroll, y_panelhdr+1, 5)
|
||||||
send(curses.KEY_RIGHT)
|
send(curses.KEY_RIGHT)
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
local str2 = string_at(1, y_panelhdr+1, 5)
|
local str2 = string_at(1, y_panelhdr+1, 5)
|
||||||
send(curses.KEY_LEFT)
|
send(curses.KEY_LEFT)
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
local str3 = string_at(1+h_scroll, y_panelhdr+1, 5)
|
local str3 = string_at(1+h_scroll, y_panelhdr+1, 5)
|
||||||
send(curses.KEY_LEFT)
|
send(curses.KEY_LEFT)
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
local str4 = string_at(1+h_scroll, y_panelhdr+1, 5)
|
local str4 = string_at(1+h_scroll, y_panelhdr+1, 5)
|
||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
assert.equal(str1, str2)
|
assert.equal(str1, str2)
|
||||||
@ -262,7 +268,7 @@ describe("htop test suite", function()
|
|||||||
local attr = rt:cellAttr(rt:rows() - 1, 30)
|
local attr = rt:cellAttr(rt:rows() - 1, 30)
|
||||||
assert.equal(attr, attrs.black_on_cyan)
|
assert.equal(attr, attrs.black_on_cyan)
|
||||||
send("\n")
|
send("\n")
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local col = find_command_x()
|
local col = find_command_x()
|
||||||
local procname = check_string_at(col, y_panelhdr + 1, "sleep 12345")
|
local procname = check_string_at(col, y_panelhdr + 1, "sleep 12345")
|
||||||
@ -270,7 +276,7 @@ describe("htop test suite", function()
|
|||||||
send("\n")
|
send("\n")
|
||||||
send("\\")
|
send("\\")
|
||||||
send(ESC)
|
send(ESC)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
assert.equal(check(procname))
|
assert.equal(check(procname))
|
||||||
assert.not_equal((os.execute("ps aux | grep -q '[s]leep 12345'")), true)
|
assert.not_equal((os.execute("ps aux | grep -q '[s]leep 12345'")), true)
|
||||||
end)
|
end)
|
||||||
@ -281,7 +287,7 @@ describe("htop test suite", function()
|
|||||||
send("busted")
|
send("busted")
|
||||||
send("\n")
|
send("\n")
|
||||||
send("s")
|
send("s")
|
||||||
delay(1)
|
delay(long_delay)
|
||||||
send(ESC)
|
send(ESC)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -291,7 +297,7 @@ describe("htop test suite", function()
|
|||||||
send("busted")
|
send("busted")
|
||||||
send("\n")
|
send("\n")
|
||||||
send("l")
|
send("l")
|
||||||
delay(1)
|
delay(long_delay)
|
||||||
send(ESC)
|
send(ESC)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -303,7 +309,7 @@ describe("htop test suite", function()
|
|||||||
send("l")
|
send("l")
|
||||||
send(curses.KEY_F4)
|
send(curses.KEY_F4)
|
||||||
send("pipe")
|
send("pipe")
|
||||||
delay(1)
|
delay(long_delay)
|
||||||
local pipefd = check_string_at(1, 3, " 3")
|
local pipefd = check_string_at(1, 3, " 3")
|
||||||
send(ESC)
|
send(ESC)
|
||||||
assert.equal(check(pipefd))
|
assert.equal(check(pipefd))
|
||||||
@ -317,7 +323,7 @@ describe("htop test suite", function()
|
|||||||
send("l")
|
send("l")
|
||||||
send(curses.KEY_F3)
|
send(curses.KEY_F3)
|
||||||
send("pipe")
|
send("pipe")
|
||||||
delay(1)
|
delay(long_delay)
|
||||||
local line = find_selected_y(3)
|
local line = find_selected_y(3)
|
||||||
local pipefd = check_string_at(1, line, " 3")
|
local pipefd = check_string_at(1, line, " 3")
|
||||||
send(ESC)
|
send(ESC)
|
||||||
@ -341,18 +347,18 @@ describe("htop test suite", function()
|
|||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
send("u")
|
send("u")
|
||||||
send(curses.KEY_DOWN)
|
send(curses.KEY_DOWN)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local chosen = string_at(1, y_panelhdr + 2, 9)
|
local chosen = string_at(1, y_panelhdr + 2, 9)
|
||||||
send("\n")
|
send("\n")
|
||||||
send(curses.KEY_HOME)
|
send(curses.KEY_HOME)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local shown = string_at(7, y_panelhdr + 1, 9)
|
local shown = string_at(7, y_panelhdr + 1, 9)
|
||||||
send("u")
|
send("u")
|
||||||
send("\n")
|
send("\n")
|
||||||
send(curses.KEY_HOME)
|
send(curses.KEY_HOME)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local inituser = string_at(7, y_panelhdr + 1, 9)
|
local inituser = string_at(7, y_panelhdr + 1, 9)
|
||||||
send(curses.KEY_F5)
|
send(curses.KEY_F5)
|
||||||
@ -364,7 +370,7 @@ describe("htop test suite", function()
|
|||||||
send(curses.KEY_HOME)
|
send(curses.KEY_HOME)
|
||||||
send("/")
|
send("/")
|
||||||
send("xxxxxxxxxx")
|
send("xxxxxxxxxx")
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local attr = rt:cellAttr(rt:rows() - 1, 30)
|
local attr = rt:cellAttr(rt:rows() - 1, 30)
|
||||||
assert.equal(attr, attrs.red_on_cyan)
|
assert.equal(attr, attrs.red_on_cyan)
|
||||||
@ -405,14 +411,14 @@ describe("htop test suite", function()
|
|||||||
send(curses.KEY_DOWN, 2)
|
send(curses.KEY_DOWN, 2)
|
||||||
send("\n")
|
send("\n")
|
||||||
send(curses.KEY_F10)
|
send(curses.KEY_F10)
|
||||||
delay(0.2)
|
delay(short_delay)
|
||||||
local ppid = check_string_at(2, y_panelhdr, "PPID")
|
local ppid = check_string_at(2, y_panelhdr, "PPID")
|
||||||
send("S")
|
send("S")
|
||||||
send(curses.KEY_DOWN, 3)
|
send(curses.KEY_DOWN, 3)
|
||||||
send(curses.KEY_RIGHT, 1)
|
send(curses.KEY_RIGHT, 1)
|
||||||
send(curses.KEY_DC)
|
send(curses.KEY_DC)
|
||||||
send(curses.KEY_F10)
|
send(curses.KEY_F10)
|
||||||
delay(0.2)
|
delay(short_delay)
|
||||||
local not_ppid = check_string_at(2, y_panelhdr, "PPID")
|
local not_ppid = check_string_at(2, y_panelhdr, "PPID")
|
||||||
assert.equal(check(ppid))
|
assert.equal(check(ppid))
|
||||||
assert.not_equal(check(not_ppid))
|
assert.not_equal(check(not_ppid))
|
||||||
@ -431,7 +437,7 @@ describe("htop test suite", function()
|
|||||||
local line = find_selected_y()
|
local line = find_selected_y()
|
||||||
local before = check_string_at(22, line, " 0")
|
local before = check_string_at(22, line, " 0")
|
||||||
send(curses.KEY_F8)
|
send(curses.KEY_F8)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
local after = check_string_at(22, line, " 1")
|
local after = check_string_at(22, line, " 1")
|
||||||
assert.equal(check(before))
|
assert.equal(check(before))
|
||||||
assert.equal(check(after))
|
assert.equal(check(after))
|
||||||
@ -444,7 +450,7 @@ describe("htop test suite", function()
|
|||||||
local line = find_selected_y()
|
local line = find_selected_y()
|
||||||
local before = string_at(22, line, 2)
|
local before = string_at(22, line, 2)
|
||||||
send(curses.KEY_F7)
|
send(curses.KEY_F7)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
local after = string_at(22, line, 2)
|
local after = string_at(22, line, 2)
|
||||||
assert.equal(before, after) -- no permissions
|
assert.equal(before, after) -- no permissions
|
||||||
end)
|
end)
|
||||||
@ -454,10 +460,10 @@ describe("htop test suite", function()
|
|||||||
send("P")
|
send("P")
|
||||||
send("I")
|
send("I")
|
||||||
send(curses.KEY_HOME)
|
send(curses.KEY_HOME)
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
local zerocpu = check_string_at(cpu_col, y_panelhdr + 1, " 0.0")
|
local zerocpu = check_string_at(cpu_col, y_panelhdr + 1, " 0.0")
|
||||||
send("I")
|
send("I")
|
||||||
delay(0.3)
|
delay(short_delay)
|
||||||
local nonzerocpu = check_string_at(cpu_col, y_panelhdr + 1, " 0.0")
|
local nonzerocpu = check_string_at(cpu_col, y_panelhdr + 1, " 0.0")
|
||||||
assert.equal(check(zerocpu))
|
assert.equal(check(zerocpu))
|
||||||
assert.not_equal(check(nonzerocpu))
|
assert.not_equal(check(nonzerocpu))
|
||||||
@ -483,20 +489,18 @@ describe("htop test suite", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
running_it("moves meters around", function()
|
running_it("moves meters around", function()
|
||||||
if branch == "wip" then
|
send("S")
|
||||||
send("S")
|
send(curses.KEY_RIGHT)
|
||||||
send(curses.KEY_RIGHT)
|
send(curses.KEY_UP)
|
||||||
send(curses.KEY_UP)
|
send("\n")
|
||||||
send("\n")
|
send(curses.KEY_DOWN)
|
||||||
send(curses.KEY_DOWN)
|
send(curses.KEY_UP)
|
||||||
send(curses.KEY_UP)
|
send(curses.KEY_RIGHT)
|
||||||
send(curses.KEY_RIGHT)
|
send(curses.KEY_RIGHT)
|
||||||
send(curses.KEY_RIGHT)
|
send(curses.KEY_LEFT)
|
||||||
send(curses.KEY_LEFT)
|
send(curses.KEY_LEFT)
|
||||||
send(curses.KEY_LEFT)
|
send("\n")
|
||||||
send("\n")
|
send(curses.KEY_F10)
|
||||||
send(curses.KEY_F10)
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local meters = {
|
local meters = {
|
||||||
@ -504,7 +508,7 @@ describe("htop test suite", function()
|
|||||||
{ name = "load", down = 2, string = "Load" },
|
{ name = "load", down = 2, string = "Load" },
|
||||||
{ name = "battery", down = 7, string = "Battery" },
|
{ name = "battery", down = 7, string = "Battery" },
|
||||||
{ name = "hostname", down = 8, string = "Hostname" },
|
{ name = "hostname", down = 8, string = "Hostname" },
|
||||||
{ name = "memory", down = 3, string = "Memory" },
|
{ name = "memory", down = 3, string = "Mem" },
|
||||||
{ name = "CPU average", down = 16, string = "Avg" },
|
{ name = "CPU average", down = 16, string = "Avg" },
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,19 +517,11 @@ describe("htop test suite", function()
|
|||||||
send(curses.KEY_RIGHT, 3)
|
send(curses.KEY_RIGHT, 3)
|
||||||
send(curses.KEY_DOWN, 9, "quick")
|
send(curses.KEY_DOWN, 9, "quick")
|
||||||
for _ = 9, 14 do
|
for _ = 9, 14 do
|
||||||
if branch == "wip" then
|
send("\n")
|
||||||
send("\n")
|
send("\n")
|
||||||
send("\n")
|
send(curses.KEY_DC)
|
||||||
send(curses.KEY_DC)
|
send(curses.KEY_RIGHT)
|
||||||
send(curses.KEY_RIGHT)
|
send(curses.KEY_DOWN)
|
||||||
send(curses.KEY_DOWN)
|
|
||||||
else
|
|
||||||
send(curses.KEY_F6)
|
|
||||||
send(curses.KEY_LEFT)
|
|
||||||
send(curses.KEY_DC)
|
|
||||||
send(curses.KEY_RIGHT)
|
|
||||||
send(curses.KEY_DOWN, 4)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -534,22 +530,15 @@ describe("htop test suite", function()
|
|||||||
send("S")
|
send("S")
|
||||||
send(curses.KEY_RIGHT, 3)
|
send(curses.KEY_RIGHT, 3)
|
||||||
send(curses.KEY_DOWN, item.down)
|
send(curses.KEY_DOWN, item.down)
|
||||||
if branch == "wip" then
|
send("\n")
|
||||||
send("\n")
|
send(curses.KEY_UP, 4)
|
||||||
send(curses.KEY_UP, 4)
|
send("\n")
|
||||||
send("\n")
|
|
||||||
else
|
|
||||||
send(curses.KEY_F6)
|
|
||||||
send(curses.KEY_LEFT)
|
|
||||||
send(curses.KEY_DOWN, 4)
|
|
||||||
send(curses.KEY_F7, 4)
|
|
||||||
end
|
|
||||||
send(curses.KEY_F4, 4) -- cycle through meter modes
|
send(curses.KEY_F4, 4) -- cycle through meter modes
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
rt:update()
|
rt:update()
|
||||||
local with = check_string_at(x_metercol2, 2, item.string)
|
local with = check_string_at(x_metercol2, 2, item.string)
|
||||||
send(curses.KEY_DC)
|
send(curses.KEY_DC)
|
||||||
delay(0.15)
|
delay(short_delay)
|
||||||
local without = check_string_at(x_metercol2, 2, item.string)
|
local without = check_string_at(x_metercol2, 2, item.string)
|
||||||
send(curses.KEY_F10)
|
send(curses.KEY_F10)
|
||||||
assert.equal(check(with))
|
assert.equal(check(with))
|
||||||
@ -590,7 +579,7 @@ describe("htop test suite", function()
|
|||||||
running_it("checks display option to "..item.name, function()
|
running_it("checks display option to "..item.name, function()
|
||||||
for _ = 1, 2 do
|
for _ = 1, 2 do
|
||||||
set_display_option(item.down)
|
set_display_option(item.down)
|
||||||
delay(0.1)
|
delay(short_delay)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -609,7 +598,7 @@ describe("htop test suite", function()
|
|||||||
send(curses.KEY_RIGHT)
|
send(curses.KEY_RIGHT)
|
||||||
send(curses.KEY_F4, 4) -- cycle through CPU meter modes
|
send(curses.KEY_F4, 4) -- cycle through CPU meter modes
|
||||||
send(curses.KEY_F10)
|
send(curses.KEY_F10)
|
||||||
delay(0.1)
|
delay(short_delay)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -636,7 +625,7 @@ describe("htop test suite", function()
|
|||||||
for y = y_panelhdr + 2, 23 do
|
for y = y_panelhdr + 2, 23 do
|
||||||
table.insert(taggedattrs, rt:cellAttr(y-1, 4))
|
table.insert(taggedattrs, rt:cellAttr(y-1, 4))
|
||||||
end
|
end
|
||||||
delay(0.2)
|
delay(short_delay)
|
||||||
send("U")
|
send("U")
|
||||||
local untaggedattrs = {}
|
local untaggedattrs = {}
|
||||||
rt:update()
|
rt:update()
|
||||||
@ -687,6 +676,7 @@ describe("htop test suite", function()
|
|||||||
send("q")
|
send("q")
|
||||||
while not terminated() do
|
while not terminated() do
|
||||||
unistd.sleep(1)
|
unistd.sleep(1)
|
||||||
|
send("q")
|
||||||
end
|
end
|
||||||
assert(terminated())
|
assert(terminated())
|
||||||
if visual then
|
if visual then
|
||||||
|
@ -19,9 +19,16 @@ in the source distribution for its full text.
|
|||||||
/*{
|
/*{
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
|
#include "SignalsPanel.h"
|
||||||
#include "UnsupportedProcess.h"
|
#include "UnsupportedProcess.h"
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
SignalItem Platform_signals[] = {
|
||||||
|
{ .name = " 0 Cancel", .number = 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
|
||||||
|
|
||||||
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
|
||||||
|
|
||||||
ProcessFieldData Process_fields[] = {
|
ProcessFieldData Process_fields[] = {
|
||||||
@ -79,7 +86,12 @@ void Platform_setBindings(Htop_Action* keys) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Platform_numberOfFields = 100;
|
int Platform_numberOfFields = 100;
|
||||||
char* Process_pidFormat = "%7u ";
|
|
||||||
|
extern char Process_pidFormat[20];
|
||||||
|
|
||||||
|
ProcessPidColumn Process_pidColumns[] = {
|
||||||
|
{ .id = 0, .label = NULL },
|
||||||
|
};
|
||||||
|
|
||||||
int Platform_getUptime() {
|
int Platform_getUptime() {
|
||||||
return 0;
|
return 0;
|
||||||
@ -95,42 +107,26 @@ int Platform_getMaxPid() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_setupColumnWidths() {
|
|
||||||
int maxPid = Platform_getMaxPid();
|
|
||||||
if (maxPid == -1) return;
|
|
||||||
if (maxPid > 99999) {
|
|
||||||
Process_fields[PID].title = " PID ";
|
|
||||||
Process_fields[PPID].title = " PPID ";
|
|
||||||
Process_fields[TPGID].title = " TPGID ";
|
|
||||||
Process_fields[TGID].title = " TGID ";
|
|
||||||
Process_fields[PGRP].title = " PGRP ";
|
|
||||||
Process_fields[SESSION].title = " SESN ";
|
|
||||||
Process_pidFormat = "%7u ";
|
|
||||||
} else {
|
|
||||||
Process_fields[PID].title = " PID ";
|
|
||||||
Process_fields[PPID].title = " PPID ";
|
|
||||||
Process_fields[TPGID].title = "TPGID ";
|
|
||||||
Process_fields[TGID].title = " TGID ";
|
|
||||||
Process_fields[PGRP].title = " PGRP ";
|
|
||||||
Process_fields[SESSION].title = " SESN ";
|
|
||||||
Process_pidFormat = "%5u ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double Platform_setCPUValues(Meter* this, int cpu) {
|
double Platform_setCPUValues(Meter* this, int cpu) {
|
||||||
return 0.0;
|
(void) this;
|
||||||
|
(void) cpu;
|
||||||
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_setMemoryValues(Meter* this) {
|
void Platform_setMemoryValues(Meter* this) {
|
||||||
|
(void) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Platform_setSwapValues(Meter* this) {
|
void Platform_setSwapValues(Meter* this) {
|
||||||
|
(void) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process_isThread(Process* this) {
|
bool Process_isThread(Process* this) {
|
||||||
|
(void) this;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* Platform_getProcessEnv(pid_t pid) {
|
char* Platform_getProcessEnv(pid_t pid) {
|
||||||
|
(void) pid;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,13 @@ in the source distribution for its full text.
|
|||||||
|
|
||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "BatteryMeter.h"
|
#include "BatteryMeter.h"
|
||||||
|
#include "SignalsPanel.h"
|
||||||
#include "UnsupportedProcess.h"
|
#include "UnsupportedProcess.h"
|
||||||
|
|
||||||
|
extern SignalItem Platform_signals[];
|
||||||
|
|
||||||
|
extern unsigned int Platform_numberOfSignals;
|
||||||
|
|
||||||
extern ProcessField Platform_defaultFields[];
|
extern ProcessField Platform_defaultFields[];
|
||||||
|
|
||||||
extern ProcessFieldData Process_fields[];
|
extern ProcessFieldData Process_fields[];
|
||||||
@ -23,7 +28,10 @@ extern MeterClass* Platform_meterTypes[];
|
|||||||
void Platform_setBindings(Htop_Action* keys);
|
void Platform_setBindings(Htop_Action* keys);
|
||||||
|
|
||||||
extern int Platform_numberOfFields;
|
extern int Platform_numberOfFields;
|
||||||
extern char* Process_pidFormat;
|
|
||||||
|
extern char Process_pidFormat[20];
|
||||||
|
|
||||||
|
extern ProcessPidColumn Process_pidColumns[];
|
||||||
|
|
||||||
int Platform_getUptime();
|
int Platform_getUptime();
|
||||||
|
|
||||||
@ -31,8 +39,6 @@ void Platform_getLoadAverage(double* one, double* five, double* fifteen);
|
|||||||
|
|
||||||
int Platform_getMaxPid();
|
int Platform_getMaxPid();
|
||||||
|
|
||||||
void Process_setupColumnWidths();
|
|
||||||
|
|
||||||
double Platform_setCPUValues(Meter* this, int cpu);
|
double Platform_setCPUValues(Meter* this, int cpu);
|
||||||
|
|
||||||
void Platform_setMemoryValues(Meter* this);
|
void Platform_setMemoryValues(Meter* this);
|
||||||
|
Reference in New Issue
Block a user