mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-15 13:34:35 +03:00
Compare commits
28 Commits
3.0.0beta4
...
3.0.0beta5
Author | SHA1 | Date | |
---|---|---|---|
a4f4ef5b63 | |||
8c43218aa0 | |||
e77a16f4ae | |||
a49853543e | |||
28a5859fe8 | |||
0939e5cb41 | |||
e1c2dc56fd | |||
e9f95da559 | |||
5a0a4e1adb | |||
f3b47c46e6 | |||
34b147e14e | |||
03e0a73d5b | |||
794419e6c5 | |||
7ec5312974 | |||
af92f0b8d6 | |||
22e9d09723 | |||
fda1475a10 | |||
ebf3cff1ac | |||
7bbb3600fc | |||
4092c90bc3 | |||
7742e17cc0 | |||
2dffee8de9 | |||
791aae87c4 | |||
505fa6b517 | |||
f94c54eb5a | |||
9710ce6c08 | |||
f78f658eed | |||
b8bfe60d2b |
1
.gitignore
vendored
1
.gitignore
vendored
@ -20,6 +20,7 @@ htop
|
||||
.deps/
|
||||
Makefile
|
||||
Makefile.in
|
||||
INSTALL
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
compile
|
||||
|
37
Action.c
37
Action.c
@ -26,6 +26,7 @@ in the source distribution for its full text.
|
||||
#include <math.h>
|
||||
#include <pwd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
@ -80,7 +81,7 @@ Object* Action_pickFromVector(State* st, Panel* list, int x) {
|
||||
header->pl->following = pid;
|
||||
unfollow = true;
|
||||
}
|
||||
ScreenManager_run(scr, &panelFocus, &ch);
|
||||
ScreenManager_run(scr, &panelFocus, &ch, NULL);
|
||||
if (unfollow) {
|
||||
header->pl->following = -1;
|
||||
}
|
||||
@ -106,7 +107,7 @@ static void Action_runSetup(Settings* settings, const Header* header, ProcessLis
|
||||
CategoriesPanel_makeMetersPage(panelCategories);
|
||||
Panel* panelFocus;
|
||||
int ch;
|
||||
ScreenManager_run(scr, &panelFocus, &ch);
|
||||
ScreenManager_run(scr, &panelFocus, &ch, "Setup");
|
||||
ScreenManager_delete(scr);
|
||||
if (settings->changed) {
|
||||
Header_writeBackToSettings(header);
|
||||
@ -305,6 +306,35 @@ static Htop_Reaction actionNextScreen(State* st) {
|
||||
return HTOP_REFRESH;
|
||||
}
|
||||
|
||||
static Htop_Reaction actionPrevScreen(State* st) {
|
||||
Settings* settings = st->settings;
|
||||
if (settings->ssIndex == 0) {
|
||||
settings->ssIndex = settings->nScreens - 1;
|
||||
} else {
|
||||
settings->ssIndex--;
|
||||
}
|
||||
settings->ss = settings->screens[settings->ssIndex];
|
||||
return HTOP_REFRESH;
|
||||
}
|
||||
|
||||
Htop_Reaction Action_setScreenTab(Settings* settings, int x) {
|
||||
int s = 2;
|
||||
for (unsigned int i = 0; i < settings->nScreens; i++) {
|
||||
if (x < s) {
|
||||
return 0;
|
||||
}
|
||||
const char* name = settings->screens[i]->name;
|
||||
int len = strlen(name);
|
||||
if (x <= s + len + 1) {
|
||||
settings->ssIndex = i;
|
||||
settings->ss = settings->screens[i];
|
||||
return HTOP_REFRESH;
|
||||
}
|
||||
s += len + 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static Htop_Reaction actionSetAffinity(State* st) {
|
||||
if (st->pl->cpuCount == 1)
|
||||
return HTOP_OK;
|
||||
@ -487,7 +517,7 @@ static Htop_Reaction actionHelp(State* st) {
|
||||
addattrstr(CRT_colors[CPU_NICE_TEXT], "low-priority"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_NORMAL], "normal"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_KERNEL], "kernel"); addstr("/");
|
||||
addattrstr(CRT_colors[CPU_STEAL], "virtualiz");
|
||||
addattrstr(CRT_colors[CPU_GUEST], "virtualiz");
|
||||
addattrstr(CRT_colors[BAR_SHADOW], " used%");
|
||||
}
|
||||
addattrstr(CRT_colors[BAR_BORDER], "]");
|
||||
@ -610,5 +640,6 @@ void Action_setBindings(Htop_Action* keys) {
|
||||
keys['c'] = actionTagAllChildren;
|
||||
keys['e'] = actionShowEnvScreen;
|
||||
keys['\t'] = actionNextScreen;
|
||||
keys[KEY_SHIFT_TAB] = actionPrevScreen;
|
||||
}
|
||||
|
||||
|
2
Action.h
2
Action.h
@ -49,6 +49,8 @@ Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey);
|
||||
|
||||
// ----------------------------------------
|
||||
|
||||
Htop_Reaction Action_setScreenTab(Settings* settings, int x);
|
||||
|
||||
Htop_Reaction Action_follow(State* st);
|
||||
|
||||
|
||||
|
33
CRT.c
33
CRT.c
@ -42,6 +42,7 @@ in the source distribution for its full text.
|
||||
#define KEY_WHEELUP KEY_F(20)
|
||||
#define KEY_WHEELDOWN KEY_F(21)
|
||||
#define KEY_RECLICK KEY_F(22)
|
||||
#define KEY_SHIFT_TAB KEY_F(23)
|
||||
|
||||
//#link curses
|
||||
|
||||
@ -129,6 +130,10 @@ typedef enum ColorElements_ {
|
||||
CPU_STEAL,
|
||||
CPU_GUEST,
|
||||
PANEL_EDIT,
|
||||
SCREENS_OTH_BORDER,
|
||||
SCREENS_OTH_TEXT,
|
||||
SCREENS_CUR_BORDER,
|
||||
SCREENS_CUR_TEXT,
|
||||
LAST_COLORELEMENT
|
||||
} ColorElements;
|
||||
|
||||
@ -234,6 +239,10 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[CPU_STEAL] = ColorPair(Cyan,Black),
|
||||
[CPU_GUEST] = ColorPair(Cyan,Black),
|
||||
[PANEL_EDIT] = ColorPair(White,Blue),
|
||||
[SCREENS_OTH_BORDER] = ColorPair(Blue,Blue),
|
||||
[SCREENS_OTH_TEXT] = ColorPair(Black,Blue),
|
||||
[SCREENS_CUR_BORDER] = ColorPair(Green,Green),
|
||||
[SCREENS_CUR_TEXT] = ColorPair(Black,Green),
|
||||
},
|
||||
[COLORSCHEME_MONOCHROME] = {
|
||||
[RESET_COLOR] = A_NORMAL,
|
||||
@ -294,6 +303,10 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[CPU_STEAL] = A_REVERSE,
|
||||
[CPU_GUEST] = A_REVERSE,
|
||||
[PANEL_EDIT] = A_BOLD,
|
||||
[SCREENS_OTH_BORDER] = A_DIM,
|
||||
[SCREENS_OTH_TEXT] = A_DIM,
|
||||
[SCREENS_CUR_BORDER] = A_REVERSE,
|
||||
[SCREENS_CUR_TEXT] = A_REVERSE,
|
||||
},
|
||||
[COLORSCHEME_BLACKONWHITE] = {
|
||||
[RESET_COLOR] = ColorPair(Black,White),
|
||||
@ -354,6 +367,10 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[CPU_STEAL] = ColorPair(Cyan,White),
|
||||
[CPU_GUEST] = ColorPair(Cyan,White),
|
||||
[PANEL_EDIT] = ColorPair(White,Blue),
|
||||
[SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Black,White),
|
||||
[SCREENS_OTH_TEXT] = A_BOLD | ColorPair(Black,White),
|
||||
[SCREENS_CUR_BORDER] = ColorPair(Green,Green),
|
||||
[SCREENS_CUR_TEXT] = ColorPair(Black,Green),
|
||||
},
|
||||
[COLORSCHEME_LIGHTTERMINAL] = {
|
||||
[RESET_COLOR] = ColorPair(Black,Black),
|
||||
@ -414,6 +431,10 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[CPU_STEAL] = ColorPair(Black,Black),
|
||||
[CPU_GUEST] = ColorPair(Black,Black),
|
||||
[PANEL_EDIT] = ColorPair(White,Blue),
|
||||
[SCREENS_OTH_BORDER] = ColorPair(Blue,Black),
|
||||
[SCREENS_OTH_TEXT] = ColorPair(Blue,Black),
|
||||
[SCREENS_CUR_BORDER] = ColorPair(Green,Green),
|
||||
[SCREENS_CUR_TEXT] = ColorPair(Black,Green),
|
||||
},
|
||||
[COLORSCHEME_MIDNIGHT] = {
|
||||
[RESET_COLOR] = ColorPair(White,Blue),
|
||||
@ -474,6 +495,10 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[CPU_STEAL] = ColorPair(White,Blue),
|
||||
[CPU_GUEST] = ColorPair(White,Blue),
|
||||
[PANEL_EDIT] = ColorPair(White,Blue),
|
||||
[SCREENS_OTH_BORDER] = A_BOLD | ColorPair(Yellow,Blue),
|
||||
[SCREENS_OTH_TEXT] = ColorPair(Cyan,Blue),
|
||||
[SCREENS_CUR_BORDER] = ColorPair(Cyan,Cyan),
|
||||
[SCREENS_CUR_TEXT] = ColorPair(Black,Cyan),
|
||||
},
|
||||
[COLORSCHEME_BLACKNIGHT] = {
|
||||
[RESET_COLOR] = ColorPair(Cyan,Black),
|
||||
@ -534,6 +559,10 @@ int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
||||
[CPU_STEAL] = ColorPair(Cyan,Black),
|
||||
[CPU_GUEST] = ColorPair(Cyan,Black),
|
||||
[PANEL_EDIT] = ColorPair(White,Cyan),
|
||||
[SCREENS_OTH_BORDER] = ColorPair(White,Black),
|
||||
[SCREENS_OTH_TEXT] = ColorPair(Cyan,Black),
|
||||
[SCREENS_CUR_BORDER] = A_BOLD | ColorPair(White,Black),
|
||||
[SCREENS_CUR_TEXT] = A_BOLD | ColorPair(Green,Black),
|
||||
},
|
||||
[COLORSCHEME_BROKENGRAY] = { 0 } // dynamically generated.
|
||||
};
|
||||
@ -646,12 +675,16 @@ void CRT_init(int delay, int colorScheme) {
|
||||
define_key("\033[13~", KEY_F(3));
|
||||
define_key("\033[14~", KEY_F(4));
|
||||
define_key("\033[17;2~", KEY_F(18));
|
||||
define_key("\033[Z", KEY_SHIFT_TAB);
|
||||
char sequence[3] = "\033a";
|
||||
for (char c = 'a'; c <= 'z'; c++) {
|
||||
sequence[1] = c;
|
||||
define_key(sequence, KEY_ALT('A' + (c - 'a')));
|
||||
}
|
||||
}
|
||||
if (String_startsWith(CRT_termType, "rxvt")) {
|
||||
define_key("\033[Z", KEY_SHIFT_TAB);
|
||||
}
|
||||
#ifndef DEBUG
|
||||
signal(11, CRT_handleSIGSEGV);
|
||||
#endif
|
||||
|
5
CRT.h
5
CRT.h
@ -31,6 +31,7 @@ in the source distribution for its full text.
|
||||
#define KEY_WHEELUP KEY_F(20)
|
||||
#define KEY_WHEELDOWN KEY_F(21)
|
||||
#define KEY_RECLICK KEY_F(22)
|
||||
#define KEY_SHIFT_TAB KEY_F(23)
|
||||
|
||||
//#link curses
|
||||
|
||||
@ -117,6 +118,10 @@ typedef enum ColorElements_ {
|
||||
CPU_STEAL,
|
||||
CPU_GUEST,
|
||||
PANEL_EDIT,
|
||||
SCREENS_OTH_BORDER,
|
||||
SCREENS_OTH_TEXT,
|
||||
SCREENS_CUR_BORDER,
|
||||
SCREENS_CUR_TEXT,
|
||||
LAST_COLORELEMENT
|
||||
} ColorElements;
|
||||
|
||||
|
@ -145,7 +145,7 @@ CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Settings* settings, Hea
|
||||
this->settings = settings;
|
||||
this->header = header;
|
||||
this->pl = pl;
|
||||
Panel_setHeader(super, "Setup");
|
||||
Panel_setHeader(super, "Categories");
|
||||
Panel_add(super, (Object*) ListItem_new("Meters", 0));
|
||||
Panel_add(super, (Object*) ListItem_new("Display options", 0));
|
||||
Panel_add(super, (Object*) ListItem_new("Colors", 0));
|
||||
|
31
ChangeLog
31
ChangeLog
@ -1,21 +1,38 @@
|
||||
What's new in version 2.1.1
|
||||
What's new in version 2.2.0
|
||||
|
||||
* Solaris/Illumos/OpenIndiana support
|
||||
(thanks to Guy M. Broome)
|
||||
* -t/--tree flag for starting in tree-view mode
|
||||
(thanks to Daniel Flanagan)
|
||||
* macOS: detects High Sierra version to avoid OS bug
|
||||
(thanks to Pierre Malhaire)
|
||||
* OpenBSD: read battery data
|
||||
(thanks to @nerd972)
|
||||
* Various automake and build improvements
|
||||
(thanks to Kang-Che Sung)
|
||||
* Check for pkg-config when building with --enable-delayacct
|
||||
(thanks to @florian2833z for the report)
|
||||
* Avoid some bashisms in configure script
|
||||
(thanks to Jesin)
|
||||
* Use CFLAGS from ncurses*-config if present
|
||||
(thanks to Michael Klein)
|
||||
* Fix build failure in Glibc 2.28
|
||||
(thanks to Kang-Che Sung)
|
||||
* Header generator supports non-UTF-8 environments
|
||||
(thanks to @volkov-am)
|
||||
* Linux: changed detection of kernel threads
|
||||
* Collapse current subtree pressing Backspace
|
||||
* BUGFIX: fix behavior of SYSCR column
|
||||
(thanks to Marc Kleine-Budde)
|
||||
* BUGFIX: preserve LDFLAGS when building
|
||||
(thanks to Lance Frederickson for the report)
|
||||
* BUGFIX: fix issue with small terminals
|
||||
(thanks to Daniel Elf for the report)
|
||||
* BUGFIX: obtain exit code of lsof correctly
|
||||
(thanks to @wangqr)
|
||||
* BUGFIX: fix crash with particular keycodes
|
||||
(thanks to Wellington Torrejais da Silva for the report)
|
||||
* BUGFIX: fix issue with small terminals
|
||||
(thanks to Daniel Elf for the report)
|
||||
* BUGFIX: fix terminal color issues
|
||||
(thanks to Kang-Che Sung for the report)
|
||||
* BUGFIX: preserve LDFLAGS when building
|
||||
(thanks to Lance Frederickson for the report)
|
||||
* BUGFIX: fixed overflow for systems with >= 100 signals
|
||||
|
||||
What's new in version 2.1.0
|
||||
|
||||
|
@ -96,5 +96,6 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
|
||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Count CPUs from 0 instead of 1"), &(settings->countCPUsFromZero)));
|
||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Update process names on every refresh"), &(settings->updateProcessNames)));
|
||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Add guest time in CPU meter percentage"), &(settings->accountGuestInCPUMeter)));
|
||||
Panel_add(super, (Object*) CheckItem_newByRef(xStrdup("Show tabs for screens"), &(settings->screenTabs)));
|
||||
return this;
|
||||
}
|
||||
|
3
Header.c
3
Header.c
@ -211,6 +211,9 @@ int Header_calculateHeight(Header* this) {
|
||||
}
|
||||
maxHeight = MAX(maxHeight, height);
|
||||
}
|
||||
if (this->settings->screenTabs) {
|
||||
maxHeight++;
|
||||
}
|
||||
this->height = maxHeight;
|
||||
this->pad = pad;
|
||||
return maxHeight;
|
||||
|
370
INSTALL
370
INSTALL
@ -1,370 +0,0 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
|
||||
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
|
||||
==================
|
||||
|
||||
Briefly, the shell command `./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
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.
|
||||
|
||||
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
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||
you want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system.
|
||||
|
||||
Running `configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
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. 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
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
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
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
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
|
||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'. This
|
||||
is known as a "VPATH" build.
|
||||
|
||||
With a non-GNU `make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use `make distclean' before
|
||||
reconfiguring 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
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
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
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--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
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS
|
||||
KERNEL-OS
|
||||
|
||||
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
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
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' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
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'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`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 --help' for more details.
|
@ -88,6 +88,10 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
||||
}
|
||||
reaction |= HTOP_RECALCULATE | HTOP_REDRAW_BAR | HTOP_SAVE_SETTINGS;
|
||||
result = HANDLED;
|
||||
} else if (EVENT_IS_SCREEN_TAB_CLICK(ch)) {
|
||||
int x = EVENT_SCREEN_TAB_GET_X(ch);
|
||||
reaction |= Action_setScreenTab(settings, x);
|
||||
result = HANDLED;
|
||||
} else if (ch != ERR && this->inc->active) {
|
||||
bool filterChanged = IncSet_handleKey(this->inc, ch, super, (IncMode_GetPanelValue) MainPanel_getValue, NULL);
|
||||
if (filterChanged) {
|
||||
|
@ -215,6 +215,13 @@ coverage:
|
||||
cppcheck:
|
||||
cppcheck -q -v . --enable=all -DHAVE_CGROUP -DHAVE_OPENVZ -DHAVE_TASKSTATS
|
||||
|
||||
dist-hook: $(top_distdir)/configure
|
||||
@if grep 'pkg_m4_absent' '$(top_distdir)/configure'; then \
|
||||
echo 'configure is generated without pkg.m4. Please supply pkg.m4 and run ./autogen.sh to rebuild the configure script.'>&2; \
|
||||
(exit 1); \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
.PHONY: lcov
|
||||
|
||||
lcov:
|
||||
|
6
Panel.c
6
Panel.c
@ -40,8 +40,12 @@ typedef enum HandlerResult_ {
|
||||
#define EVENT_SET_SELECTED -1
|
||||
|
||||
#define EVENT_HEADER_CLICK(x_) (-10000 + x_)
|
||||
#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ <= -9000)
|
||||
#define EVENT_HEADER_CLICK_GET_X(ev_) (ev_ + 10000)
|
||||
#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ < -9000)
|
||||
|
||||
#define EVENT_SCREEN_TAB_CLICK(x_) (-20000 + x_)
|
||||
#define EVENT_SCREEN_TAB_GET_X(ev_) (ev_ + 20000)
|
||||
#define EVENT_IS_SCREEN_TAB_CLICK(ev_) (ev_ >= -20000 && ev_ < -10000)
|
||||
|
||||
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
|
||||
|
||||
|
6
Panel.h
6
Panel.h
@ -29,8 +29,12 @@ typedef enum HandlerResult_ {
|
||||
#define EVENT_SET_SELECTED -1
|
||||
|
||||
#define EVENT_HEADER_CLICK(x_) (-10000 + x_)
|
||||
#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ <= -9000)
|
||||
#define EVENT_HEADER_CLICK_GET_X(ev_) (ev_ + 10000)
|
||||
#define EVENT_IS_HEADER_CLICK(ev_) (ev_ >= -10000 && ev_ < -9000)
|
||||
|
||||
#define EVENT_SCREEN_TAB_CLICK(x_) (-20000 + x_)
|
||||
#define EVENT_SCREEN_TAB_GET_X(ev_) (ev_ + 20000)
|
||||
#define EVENT_IS_SCREEN_TAB_CLICK(ev_) (ev_ >= -20000 && ev_ < -10000)
|
||||
|
||||
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
|
||||
|
||||
|
@ -13,6 +13,7 @@ in the source distribution for its full text.
|
||||
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@ -35,6 +36,7 @@ typedef struct ScreenManager_ {
|
||||
int y2;
|
||||
Orientation orientation;
|
||||
Vector* panels;
|
||||
const char* name;
|
||||
int panelCount;
|
||||
const Header* header;
|
||||
const Settings* settings;
|
||||
@ -160,7 +162,50 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
|
||||
*rescan = false;
|
||||
}
|
||||
|
||||
static inline bool drawTab(int* y, int* x, int l, const char* name, bool cur) {
|
||||
attrset(CRT_colors[cur ? SCREENS_CUR_BORDER : SCREENS_OTH_BORDER]);
|
||||
mvaddch(*y, *x, '[');
|
||||
(*x)++;
|
||||
if (*x >= l) return false;
|
||||
int nameLen = strlen(name);
|
||||
int n = MIN(l - *x, nameLen);
|
||||
attrset(CRT_colors[cur ? SCREENS_CUR_TEXT : SCREENS_OTH_TEXT]);
|
||||
mvaddnstr(*y, *x, name, n);
|
||||
*x += n;
|
||||
if (*x >= l) return false;
|
||||
attrset(CRT_colors[cur ? SCREENS_CUR_BORDER : SCREENS_OTH_BORDER]);
|
||||
mvaddch(*y, *x, ']');
|
||||
*x += 2;
|
||||
if (*x >= l) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ScreenManager_drawScreenTabs(ScreenManager* this) {
|
||||
ScreenSettings** screens = this->settings->screens;
|
||||
int cur = this->settings->ssIndex;
|
||||
int l = COLS;
|
||||
Panel* panel = (Panel*) Vector_get(this->panels, 0);
|
||||
int y = panel->y - 1;
|
||||
int x = 2;
|
||||
|
||||
if (this->name) {
|
||||
drawTab(&y, &x, l, this->name, true);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int s = 0; screens[s]; s++) {
|
||||
bool ok = drawTab(&y, &x, l, screens[s]->name, s == cur);
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
attrset(CRT_colors[RESET_COLOR]);
|
||||
}
|
||||
|
||||
static void ScreenManager_drawPanels(ScreenManager* this, int focus) {
|
||||
if (this->settings->screenTabs) {
|
||||
ScreenManager_drawScreenTabs(this);
|
||||
}
|
||||
int nPanels = this->panelCount;
|
||||
for (int i = 0; i < nPanels; i++) {
|
||||
Panel* panel = (Panel*) Vector_get(this->panels, i);
|
||||
@ -179,7 +224,7 @@ static Panel* setCurrentPanel(ScreenManager* this, int focus) {
|
||||
return panel;
|
||||
}
|
||||
|
||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, char* name) {
|
||||
bool quit = false;
|
||||
int focus = 0;
|
||||
|
||||
@ -195,6 +240,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||
bool rescan = false;
|
||||
int sortTimeout = 0;
|
||||
int resetSortTimeout = 5;
|
||||
|
||||
this->name = name;
|
||||
|
||||
while (!quit) {
|
||||
if (this->header) {
|
||||
@ -224,6 +271,9 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||
if (mevent.y == panel->y) {
|
||||
ch = EVENT_HEADER_CLICK(mevent.x - panel->x);
|
||||
break;
|
||||
} else if (this->settings->screenTabs && mevent.y == panel->y - 1) {
|
||||
ch = EVENT_SCREEN_TAB_CLICK(mevent.x);
|
||||
break;
|
||||
} else if (mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
|
||||
ch = KEY_MOUSE;
|
||||
if (panel == panelFocus || this->allowFocusChange) {
|
||||
|
@ -27,6 +27,7 @@ typedef struct ScreenManager_ {
|
||||
int y2;
|
||||
Orientation orientation;
|
||||
Vector* panels;
|
||||
const char* name;
|
||||
int panelCount;
|
||||
const Header* header;
|
||||
const Settings* settings;
|
||||
@ -49,6 +50,6 @@ Panel* ScreenManager_remove(ScreenManager* this, int idx);
|
||||
|
||||
void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2);
|
||||
|
||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
|
||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, char* name);
|
||||
|
||||
#endif
|
||||
|
@ -149,6 +149,7 @@ static void rebuildSettingsArray(Panel* super) {
|
||||
ScreenListItem* item = (ScreenListItem*) Panel_get(super, i);
|
||||
this->settings->screens[i] = item->ss;
|
||||
}
|
||||
this->settings->nScreens = n;
|
||||
}
|
||||
|
||||
static void addNewScreen(Panel* super) {
|
||||
|
13
Settings.c
13
Settings.c
@ -73,6 +73,7 @@ typedef struct Settings_ {
|
||||
bool updateProcessNames;
|
||||
bool accountGuestInCPUMeter;
|
||||
bool headerMargin;
|
||||
bool screenTabs;
|
||||
|
||||
bool changed;
|
||||
} Settings;
|
||||
@ -216,6 +217,9 @@ static void Settings_defaultMeters(Settings* this) {
|
||||
}
|
||||
|
||||
static const char* toFieldName(int i) {
|
||||
if (i < 0 || i > LAST_PROCESSFIELD) {
|
||||
return "";
|
||||
}
|
||||
return Process_fields[i].name;
|
||||
}
|
||||
|
||||
@ -264,6 +268,7 @@ ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char*
|
||||
ss->direction = 1;
|
||||
ss->treeView = 0;
|
||||
readFields(ss->fields, &(ss->flags), line);
|
||||
ss->sortKey = ss->fields[0];
|
||||
this->screens[this->nScreens] = ss;
|
||||
this->nScreens++;
|
||||
this->screens = xRealloc(this->screens, sizeof(ScreenSettings*) * (this->nScreens + 1));
|
||||
@ -275,7 +280,7 @@ static void Settings_defaultScreens(Settings* this) {
|
||||
for (unsigned int i = 0; i < Platform_numberOfDefaultScreens; i++) {
|
||||
ScreenDefaults* defaults = &Platform_defaultScreens[i];
|
||||
Settings_newScreen(this, defaults->name, defaults->columns);
|
||||
this->screens[0]->sortKey = toFieldIndex(defaults->sortKey);
|
||||
this->screens[i]->sortKey = toFieldIndex(defaults->sortKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,6 +333,8 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
||||
this->highlightThreads = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "header_margin")) {
|
||||
this->headerMargin = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "screen_tabs")) {
|
||||
this->screenTabs = atoi(option[1]);
|
||||
} else if (String_eq(option[0], "expand_system_time")) {
|
||||
// Compatibility option.
|
||||
this->detailedCPUTime = atoi(option[1]);
|
||||
@ -358,6 +365,7 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
||||
didReadMeters = true;
|
||||
} else if (strncmp(option[0], "screen:", 7) == 0) {
|
||||
Settings_newScreen(this, option[0] + 7, option[1]);
|
||||
didReadFields = true;
|
||||
} else if (String_eq(option[0], ".tree_view")) {
|
||||
if (this->nScreens > 0) {
|
||||
this->screens[this->nScreens - 1]->treeView = atoi(option[1]);
|
||||
@ -377,6 +385,7 @@ static bool Settings_read(Settings* this, const char* fileName) {
|
||||
if (this->nScreens == 0) {
|
||||
Settings_defaultScreens(this);
|
||||
if (legacyFieldsRead) {
|
||||
didReadFields = true;
|
||||
free(this->screens[0]->fields);
|
||||
this->screens[0]->fields = legacyFields;
|
||||
this->screens[0]->flags = legacyFlags;
|
||||
@ -438,6 +447,7 @@ bool Settings_write(Settings* this) {
|
||||
fprintf(fd, "highlight_megabytes=%d\n", (int) this->highlightMegabytes);
|
||||
fprintf(fd, "highlight_threads=%d\n", (int) this->highlightThreads);
|
||||
fprintf(fd, "header_margin=%d\n", (int) this->headerMargin);
|
||||
fprintf(fd, "screen_tabs=%d\n", (int) this->screenTabs);
|
||||
fprintf(fd, "detailed_cpu_time=%d\n", (int) this->detailedCPUTime);
|
||||
fprintf(fd, "cpu_count_from_zero=%d\n", (int) this->countCPUsFromZero);
|
||||
fprintf(fd, "update_process_names=%d\n", (int) this->updateProcessNames);
|
||||
@ -554,6 +564,7 @@ Settings* Settings_new(int cpuCount) {
|
||||
this->highlightMegabytes = true;
|
||||
this->highlightThreads = true;
|
||||
this->headerMargin = true;
|
||||
this->screenTabs = true;
|
||||
}
|
||||
|
||||
this->ssIndex = 0;
|
||||
|
@ -64,6 +64,7 @@ typedef struct Settings_ {
|
||||
bool updateProcessNames;
|
||||
bool accountGuestInCPUMeter;
|
||||
bool headerMargin;
|
||||
bool screenTabs;
|
||||
|
||||
bool changed;
|
||||
} Settings;
|
||||
|
24
configure.ac
24
configure.ac
@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.65)
|
||||
AC_INIT([htop],[3.0.0beta4],[hisham@gobolinux.org])
|
||||
AC_INIT([htop],[3.0.0beta5],[hisham@gobolinux.org])
|
||||
|
||||
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
|
||||
year=$(date -u -d "@$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "+%Y" 2>/dev/null || date -u "+%Y")
|
||||
@ -245,6 +245,10 @@ if test "$my_htop_platform" = "solaris"; then
|
||||
AC_CHECK_LIB([kstat], [kstat_open], [], [missing_libraries="$missing_libraries libkstat"])
|
||||
AC_CHECK_LIB([proc], [Pgrab_error], [], [missing_libraries="$missing_libraries libproc"])
|
||||
AC_CHECK_LIB([malloc], [free], [], [missing_libraries="$missing_libraries libmalloc"])
|
||||
AC_CHECK_HEADERS([err.h],[:],[
|
||||
missing_headers="$missing_headers err.h"
|
||||
AC_MSG_ERROR([You appear to be on Solaris 10, or very early Solaris Express, which are currently unsupported.])
|
||||
])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(linux_affinity, [AS_HELP_STRING([--enable-linux-affinity], [enable Linux sched_setaffinity and sched_getaffinity for affinity support, disables hwloc])], ,enable_linux_affinity="yes")
|
||||
@ -330,12 +334,18 @@ fi
|
||||
AC_ARG_ENABLE(delayacct, [AS_HELP_STRING([--enable-delayacct], [enable linux delay accounting])],, enable_delayacct="no")
|
||||
if test "x$enable_delayacct" = xyes
|
||||
then
|
||||
PKG_PROG_PKG_CONFIG()
|
||||
PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"])
|
||||
PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"])
|
||||
CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
|
||||
LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
|
||||
AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.])
|
||||
m4_ifdef([PKG_PROG_PKG_CONFIG], [
|
||||
PKG_PROG_PKG_CONFIG()
|
||||
PKG_CHECK_MODULES(LIBNL3, libnl-3.0, [], [missing_libraries="$missing_libraries libnl-3"])
|
||||
PKG_CHECK_MODULES(LIBNL3GENL, libnl-genl-3.0, [], [missing_libraries="$missing_libraries libnl-genl-3"])
|
||||
CFLAGS="$CFLAGS $LIBNL3_CFLAGS $LIBNL3GENL_CFLAGS"
|
||||
LIBS="$LIBS $LIBNL3_LIBS $LIBNL3GENL_LIBS"
|
||||
AC_DEFINE(HAVE_DELAYACCT, 1, [Define if delay accounting support should be enabled.])
|
||||
], [
|
||||
pkg_m4_absent=1
|
||||
m4_warning([configure is generated without pkg.m4. 'make dist' target will be disabled.])
|
||||
AC_MSG_ERROR([htop on Linux requires pkg-config for checking delayacct requirements. Please install pkg-config and run ./autogen.sh to rebuild the configure script.])
|
||||
])
|
||||
fi
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ typedef enum DarwinProcessFields {
|
||||
|
||||
ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "Default",
|
||||
.name = "Main",
|
||||
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||
.sortKey = "PERCENT_CPU",
|
||||
},
|
||||
|
@ -138,14 +138,14 @@ void DragonFlyBSDProcess_writeField(Process* this, RichString* str, ProcessField
|
||||
long DragonFlyBSDProcess_compare(const void* v1, const void* v2) {
|
||||
DragonFlyBSDProcess *p1, *p2;
|
||||
Settings *settings = ((Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
if (settings->ss->direction == 1) {
|
||||
p1 = (DragonFlyBSDProcess*)v1;
|
||||
p2 = (DragonFlyBSDProcess*)v2;
|
||||
} else {
|
||||
p2 = (DragonFlyBSDProcess*)v1;
|
||||
p1 = (DragonFlyBSDProcess*)v2;
|
||||
}
|
||||
switch ((int) settings->sortKey) {
|
||||
switch ((int) settings->ss->sortKey) {
|
||||
// add Platform-specific fields here
|
||||
case JID:
|
||||
return (p1->jid - p2->jid);
|
||||
|
@ -42,7 +42,7 @@ extern ProcessFieldData Process_fields[];
|
||||
|
||||
ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "Default",
|
||||
.name = "Main",
|
||||
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||
.sortKey = "PERCENT_CPU",
|
||||
},
|
||||
|
@ -136,14 +136,14 @@ void FreeBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
||||
long FreeBSDProcess_compare(const void* v1, const void* v2) {
|
||||
FreeBSDProcess *p1, *p2;
|
||||
Settings *settings = ((Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
if (settings->ss->direction == 1) {
|
||||
p1 = (FreeBSDProcess*)v1;
|
||||
p2 = (FreeBSDProcess*)v2;
|
||||
} else {
|
||||
p2 = (FreeBSDProcess*)v1;
|
||||
p1 = (FreeBSDProcess*)v2;
|
||||
}
|
||||
switch ((int) settings->sortKey) {
|
||||
switch ((int) settings->ss->sortKey) {
|
||||
// add FreeBSD-specific fields here
|
||||
case JID:
|
||||
return (p1->jid - p2->jid);
|
||||
|
@ -41,7 +41,7 @@ extern ProcessFieldData Process_fields[];
|
||||
|
||||
ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "Default",
|
||||
.name = "Main",
|
||||
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||
.sortKey = "PERCENT_CPU",
|
||||
},
|
||||
|
12
htop.1.in
12
htop.1.in
@ -3,7 +3,7 @@
|
||||
htop \- interactive process viewer
|
||||
.SH "SYNOPSIS"
|
||||
.LP
|
||||
.B htop [\fI\-dChusv\fR]
|
||||
.B htop [\fI\-dChustv\fR]
|
||||
.SH "DESCRIPTION"
|
||||
.LP
|
||||
Htop is a free (GPL) ncurses-based process viewer for Linux.
|
||||
@ -41,6 +41,9 @@ Show only the processes of a given user
|
||||
.TP
|
||||
\fB\-v \-\-version
|
||||
Output version information and exit
|
||||
.TP
|
||||
\fB\-t \-\-tree
|
||||
Show processes in tree view
|
||||
.PP
|
||||
.br
|
||||
.SH "INTERACTIVE COMMANDS"
|
||||
@ -82,8 +85,13 @@ Tag or untag a process. Commands that can operate on multiple processes,
|
||||
like "kill", will then apply over the list of tagged processes, instead
|
||||
of the currently highlighted one.
|
||||
.TP
|
||||
.B c
|
||||
Tag the current process and its children. Commands that can operate on multiple
|
||||
processes, like "kill", will then apply over the list of tagged processes,
|
||||
instead of the currently highlighted one.
|
||||
.TP
|
||||
.B U
|
||||
Untag all processes (remove all tags added with the Space key).
|
||||
Untag all processes (remove all tags added with the Space or c keys).
|
||||
.TP
|
||||
.B s
|
||||
Trace process system calls: if strace(1) is installed, pressing this key
|
||||
|
4
htop.c
4
htop.c
@ -93,7 +93,7 @@ static CommandLineSettings parseArguments(int argc, char** argv) {
|
||||
|
||||
int opt, opti=0;
|
||||
/* Parse arguments */
|
||||
while ((opt = getopt_long(argc, argv, "hvCst::d:u:p:i", long_opts, &opti))) {
|
||||
while ((opt = getopt_long(argc, argv, "hvCs:td:u:p:i", long_opts, &opti))) {
|
||||
if (opt == EOF) break;
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
@ -237,7 +237,7 @@ int main(int argc, char** argv) {
|
||||
millisleep(75);
|
||||
ProcessList_scan(pl);
|
||||
|
||||
ScreenManager_run(scr, NULL, NULL);
|
||||
ScreenManager_run(scr, NULL, NULL, NULL);
|
||||
|
||||
attron(CRT_colors[RESET_COLOR]);
|
||||
mvhline(LINES-1, 0, ' ', COLS);
|
||||
|
70
htop.desktop
70
htop.desktop
@ -1,41 +1,9 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Version=1.0
|
||||
Name=Htop
|
||||
Type=Application
|
||||
Comment=Show System Processes
|
||||
Comment[ca]=Mostra els processos del sistema
|
||||
Comment[de]=Systemprozesse anzeigen
|
||||
Comment[en_GB]=Show System Processes
|
||||
Comment[es]=Mostrar procesos del sistema
|
||||
Comment[fi]=Katsele järjestelmän prosesseja
|
||||
Comment[fr]=Affiche les processus système
|
||||
Comment[gl]=Mostrar os procesos do sistema.
|
||||
Comment[it]=Mostra processi di sistema
|
||||
Comment[ko]=시스템 프로세스 보기
|
||||
Comment[nb]=Vis systemprosesser
|
||||
Comment[nl]=Systeemprocessen tonen
|
||||
Comment[nn]=Vis systemprosessar
|
||||
Comment[pl]=Pokaż procesy systemowe
|
||||
Comment[pt]=Mostrar os Processos do Sistema
|
||||
Comment[pt_BR]=Mostra os processos do sistema
|
||||
Comment[ru]=Просмотр списка процессов в системе
|
||||
Comment[sk]=Zobraziť systémové procesy
|
||||
Comment[sl]=Prikaz sistemskih opravil
|
||||
Comment[sr]=Приказ системских процеса
|
||||
Comment[sr@ijekavian]=Приказ системских процеса
|
||||
Comment[sr@ijekavianlatin]=Prikaz sistemskih procesa
|
||||
Comment[sr@latin]=Prikaz sistemskih procesa
|
||||
Comment[sv]=Visa systemprocesser
|
||||
Comment[tr]=Sistem Süreçlerini Göster
|
||||
Comment[uk]=Перегляд системних процесів
|
||||
Comment[zh_CN]=显示系统进程
|
||||
Comment[zh_TW]=顯示系統行程
|
||||
Terminal=true
|
||||
Exec=htop
|
||||
Icon=htop
|
||||
Categories=ConsoleOnly;System;
|
||||
GenericName=Process Viewer
|
||||
GenericName[ca]=Visor de processos
|
||||
GenericName[ca]=Visualitzador de processos
|
||||
GenericName[de]=Prozessanzeige
|
||||
GenericName[en_GB]=Process Viewer
|
||||
GenericName[es]=Visor de procesos
|
||||
@ -53,13 +21,45 @@ GenericName[pt_BR]=Visualizador de processos
|
||||
GenericName[ru]=Монитор процессов
|
||||
GenericName[sk]=Prehliadač procesov
|
||||
GenericName[sl]=Pregledovalnik opravil
|
||||
GenericName[sr]=Приказивач процеса
|
||||
GenericName[sr@ijekavian]=Приказивач процеса
|
||||
GenericName[sr@ijekavianlatin]=Prikazivač procesa
|
||||
GenericName[sr@latin]=Prikazivač procesa
|
||||
GenericName[sr]=Приказивач процеса
|
||||
GenericName[sv]=Processvisning
|
||||
GenericName[tr]=Süreç Görüntüleyici
|
||||
GenericName[uk]=Перегляд процесів
|
||||
GenericName[zh_CN]=进程查看器
|
||||
GenericName[zh_TW]=行程檢視器
|
||||
Comment=Show System Processes
|
||||
Comment[ca]=Visualitzeu els processos del sistema
|
||||
Comment[de]=Systemprozesse anzeigen
|
||||
Comment[en_GB]=Show System Processes
|
||||
Comment[es]=Mostrar procesos del sistema
|
||||
Comment[fi]=Katsele järjestelmän prosesseja
|
||||
Comment[fr]=Affiche les processus système
|
||||
Comment[gl]=Mostrar os procesos do sistema.
|
||||
Comment[it]=Mostra processi di sistema
|
||||
Comment[ko]=시스템 프로세스 보기
|
||||
Comment[nb]=Vis systemprosesser
|
||||
Comment[nl]=Systeemprocessen tonen
|
||||
Comment[nn]=Vis systemprosessar
|
||||
Comment[pl]=Pokaż procesy systemowe
|
||||
Comment[pt]=Mostrar os Processos do Sistema
|
||||
Comment[pt_BR]=Mostra os processos do sistema
|
||||
Comment[ru]=Просмотр списка процессов в системе
|
||||
Comment[sk]=Zobraziť systémové procesy
|
||||
Comment[sl]=Prikaz sistemskih opravil
|
||||
Comment[sr@ijekavian]=Приказ системских процеса
|
||||
Comment[sr@ijekavianlatin]=Prikaz sistemskih procesa
|
||||
Comment[sr@latin]=Prikaz sistemskih procesa
|
||||
Comment[sr]=Приказ системских процеса
|
||||
Comment[sv]=Visa systemprocesser
|
||||
Comment[tr]=Sistem Süreçlerini Göster
|
||||
Comment[uk]=Перегляд системних процесів
|
||||
Comment[zh_CN]=显示系统进程
|
||||
Comment[zh_TW]=顯示系統行程
|
||||
Icon=htop
|
||||
Exec=htop
|
||||
Terminal=true
|
||||
Categories=System;Monitor;ConsoleOnly;
|
||||
Keywords=system;process;task
|
||||
|
@ -15,6 +15,7 @@ in the source distribution for its full text.
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
/*{
|
||||
|
||||
@ -130,6 +131,7 @@ typedef struct LinuxProcess_ {
|
||||
long m_drs;
|
||||
long m_lrs;
|
||||
long m_dt;
|
||||
unsigned long long starttime;
|
||||
#ifdef HAVE_TASKSTATS
|
||||
unsigned long long io_rchar;
|
||||
unsigned long long io_wchar;
|
||||
@ -195,6 +197,8 @@ typedef struct LinuxProcess_ {
|
||||
|
||||
}*/
|
||||
|
||||
long long btime; /* semi-global */
|
||||
|
||||
ProcessFieldData Process_fields[] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
@ -431,6 +435,13 @@ void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field)
|
||||
case STIME: Process_printTime(str, lp->stime); return;
|
||||
case CUTIME: Process_printTime(str, lp->cutime); return;
|
||||
case CSTIME: Process_printTime(str, lp->cstime); return;
|
||||
case STARTTIME: {
|
||||
struct tm date;
|
||||
time_t starttimewall = btime + (lp->starttime / sysconf(_SC_CLK_TCK));
|
||||
(void) localtime_r(&starttimewall, &date);
|
||||
strftime(buffer, n, ((starttimewall > time(NULL) - 86400) ? "%R " : "%b%d "), &date);
|
||||
break;
|
||||
}
|
||||
#ifdef HAVE_TASKSTATS
|
||||
case RCHAR: Process_colorNumber(str, lp->io_rchar, coloring); return;
|
||||
case WCHAR: Process_colorNumber(str, lp->io_wchar, coloring); return;
|
||||
@ -514,6 +525,10 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
|
||||
}
|
||||
long long diff;
|
||||
switch ((int)settings->ss->sortKey) {
|
||||
case CMAJFLT:
|
||||
return (p2->cmajflt - p1->cmajflt);
|
||||
case CMINFLT:
|
||||
return (p2->cminflt - p1->cminflt);
|
||||
case M_DRS:
|
||||
return (p2->m_drs - p1->m_drs);
|
||||
case M_DT:
|
||||
@ -528,6 +543,12 @@ long LinuxProcess_compare(const void* v1, const void* v2) {
|
||||
case CUTIME: diff = p2->cutime - p1->cutime; goto test_diff;
|
||||
case STIME: diff = p2->stime - p1->stime; goto test_diff;
|
||||
case CSTIME: diff = p2->cstime - p1->cstime; goto test_diff;
|
||||
case STARTTIME: {
|
||||
if (p1->starttime == p2->starttime)
|
||||
return (p1->super.pid - p2->super.pid);
|
||||
else
|
||||
return (p1->starttime - p2->starttime);
|
||||
}
|
||||
#ifdef HAVE_TASKSTATS
|
||||
case RCHAR: diff = p2->io_rchar - p1->io_rchar; goto test_diff;
|
||||
case WCHAR: diff = p2->io_wchar - p1->io_wchar; goto test_diff;
|
||||
|
@ -122,6 +122,7 @@ typedef struct LinuxProcess_ {
|
||||
long m_drs;
|
||||
long m_lrs;
|
||||
long m_dt;
|
||||
unsigned long long starttime;
|
||||
#ifdef HAVE_TASKSTATS
|
||||
unsigned long long io_rchar;
|
||||
unsigned long long io_wchar;
|
||||
@ -186,6 +187,8 @@ typedef struct LinuxProcess_ {
|
||||
#endif
|
||||
|
||||
|
||||
long long btime; /* semi-global */
|
||||
|
||||
extern ProcessFieldData Process_fields[];
|
||||
|
||||
extern ProcessPidColumn Process_pidColumns[];
|
||||
|
@ -47,6 +47,8 @@ in the source distribution for its full text.
|
||||
|
||||
#include "ProcessList.h"
|
||||
|
||||
extern long long btime;
|
||||
|
||||
typedef struct CPUData_ {
|
||||
unsigned long long int totalTime;
|
||||
unsigned long long int userTime;
|
||||
@ -111,7 +113,7 @@ typedef struct LinuxProcessList_ {
|
||||
#endif
|
||||
|
||||
#ifndef PROC_LINE_LENGTH
|
||||
#define PROC_LINE_LENGTH 512
|
||||
#define PROC_LINE_LENGTH 4096
|
||||
#endif
|
||||
|
||||
}*/
|
||||
@ -230,8 +232,8 @@ static void LinuxProcessList_initNetlinkSocket(LinuxProcessList* this) {
|
||||
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) {
|
||||
LinuxProcessList* this = xCalloc(1, sizeof(LinuxProcessList));
|
||||
ProcessList* pl = &(this->super);
|
||||
|
||||
ProcessList_init(pl, Class(LinuxProcess), usersTable, pidWhiteList, userId);
|
||||
|
||||
LinuxProcessList_initTtyDrivers(this);
|
||||
|
||||
#ifdef HAVE_DELAYACCT
|
||||
@ -243,13 +245,19 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
||||
if (file == NULL) {
|
||||
CRT_fatalError("Cannot open " PROCSTATFILE);
|
||||
}
|
||||
char buffer[PROC_LINE_LENGTH + 1];
|
||||
int cpus = -1;
|
||||
int cpus = 0;
|
||||
do {
|
||||
cpus++;
|
||||
char * s = fgets(buffer, PROC_LINE_LENGTH, file);
|
||||
(void) s;
|
||||
} while (String_startsWith(buffer, "cpu"));
|
||||
char buffer[PROC_LINE_LENGTH + 1];
|
||||
if (fgets(buffer, PROC_LINE_LENGTH + 1, file) == NULL) {
|
||||
CRT_fatalError("No btime in " PROCSTATFILE);
|
||||
} else if (String_startsWith(buffer, "cpu")) {
|
||||
cpus++;
|
||||
} else if (String_startsWith(buffer, "btime ")) {
|
||||
sscanf(buffer, "btime %lld\n", &btime);
|
||||
break;
|
||||
}
|
||||
} while(true);
|
||||
|
||||
fclose(file);
|
||||
|
||||
pl->cpuCount = MAX(cpus - 1, 1);
|
||||
@ -259,7 +267,6 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
|
||||
this->cpus[i].totalTime = 1;
|
||||
this->cpus[i].totalPeriod = 1;
|
||||
}
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
@ -355,7 +362,10 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname,
|
||||
location += 1;
|
||||
process->nlwp = strtol(location, &location, 10);
|
||||
location += 1;
|
||||
for (int i=0; i<17; i++) location = strchr(location, ' ')+1;
|
||||
location = strchr(location, ' ')+1;
|
||||
lp->starttime = strtoll(location, &location, 10);
|
||||
location += 1;
|
||||
for (int i=0; i<15; i++) location = strchr(location, ' ')+1;
|
||||
process->exit_signal = strtol(location, &location, 10);
|
||||
location += 1;
|
||||
assert(location != NULL);
|
||||
@ -367,7 +377,7 @@ static bool LinuxProcessList_readStatFile(Process *process, const char* dirname,
|
||||
}
|
||||
|
||||
|
||||
static bool LinuxProcessList_statProcessDir(Process* process, const char* dirname, char* name, time_t curTime) {
|
||||
static bool LinuxProcessList_statProcessDir(Process* process, const char* dirname, char* name) {
|
||||
char filename[MAX_NAME+1];
|
||||
filename[MAX_NAME] = '\0';
|
||||
|
||||
@ -377,13 +387,6 @@ static bool LinuxProcessList_statProcessDir(Process* process, const char* dirnam
|
||||
if (statok == -1)
|
||||
return false;
|
||||
process->st_uid = sstat.st_uid;
|
||||
|
||||
struct tm date;
|
||||
time_t ctime = sstat.st_ctime;
|
||||
process->starttime_ctime = ctime;
|
||||
(void) localtime_r((time_t*) &ctime, &date);
|
||||
strftime(process->starttime_show, 7, ((ctime > curTime - 86400) ? "%R " : "%b%d "), &date);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -780,7 +783,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, const char* dirna
|
||||
}
|
||||
command[lastChar + 1] = '\0';
|
||||
process->basenameOffset = tokenEnd;
|
||||
setCommand(process, command, lastChar);
|
||||
setCommand(process, command, lastChar + 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -834,7 +837,6 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
||||
Settings* settings = pl->settings;
|
||||
ScreenSettings* ss = settings->ss;
|
||||
|
||||
time_t curTime = tv.tv_sec;
|
||||
#ifdef HAVE_TASKSTATS
|
||||
unsigned long long now = tv.tv_sec*1000LL+tv.tv_usec/1000LL;
|
||||
#endif
|
||||
@ -906,7 +908,7 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, const char*
|
||||
|
||||
if(!preExisting) {
|
||||
|
||||
if (! LinuxProcessList_statProcessDir(proc, dirname, name, curTime))
|
||||
if (! LinuxProcessList_statProcessDir(proc, dirname, name))
|
||||
goto errorReadingProcess;
|
||||
|
||||
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
|
||||
|
@ -20,6 +20,8 @@ in the source distribution for its full text.
|
||||
|
||||
#include "ProcessList.h"
|
||||
|
||||
extern long long btime;
|
||||
|
||||
typedef struct CPUData_ {
|
||||
unsigned long long int totalTime;
|
||||
unsigned long long int userTime;
|
||||
@ -84,7 +86,7 @@ typedef struct LinuxProcessList_ {
|
||||
#endif
|
||||
|
||||
#ifndef PROC_LINE_LENGTH
|
||||
#define PROC_LINE_LENGTH 512
|
||||
#define PROC_LINE_LENGTH 4096
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -84,7 +84,7 @@ const SignalItem Platform_signals[] = {
|
||||
|
||||
ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "Default",
|
||||
.name = "Main",
|
||||
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||
.sortKey = "PERCENT_CPU",
|
||||
},
|
||||
@ -101,7 +101,7 @@ ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "L1 Data Cache",
|
||||
.columns = "PID USER PERCENT_CPU L1DREADS L1DRMISSES L1DWRITES L1DWMISSES Command",
|
||||
.sortKey = "LD1READS",
|
||||
.sortKey = "L1DREADS",
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -215,14 +215,14 @@ void OpenBSDProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
||||
long OpenBSDProcess_compare(const void* v1, const void* v2) {
|
||||
OpenBSDProcess *p1, *p2;
|
||||
Settings *settings = ((Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
if (settings->ss->direction == 1) {
|
||||
p1 = (OpenBSDProcess*)v1;
|
||||
p2 = (OpenBSDProcess*)v2;
|
||||
} else {
|
||||
p2 = (OpenBSDProcess*)v1;
|
||||
p1 = (OpenBSDProcess*)v2;
|
||||
}
|
||||
switch (settings->sortKey) {
|
||||
switch (settings->ss->sortKey) {
|
||||
// add OpenBSD-specific fields here
|
||||
default:
|
||||
return Process_compare(v1, v2);
|
||||
|
@ -223,6 +223,8 @@ void ProcessList_goThroughEntries(ProcessList* this) {
|
||||
bool preExisting;
|
||||
Process* proc;
|
||||
OpenBSDProcess* fp;
|
||||
struct tm date;
|
||||
struct timeval tv;
|
||||
int count = 0;
|
||||
int i;
|
||||
|
||||
@ -232,6 +234,8 @@ void ProcessList_goThroughEntries(ProcessList* this) {
|
||||
struct kinfo_proc* kprocs = kvm_getprocs(opl->kd, KERN_PROC_ALL, 0, sizeof(struct kinfo_proc), &count);
|
||||
//struct kinfo_proc* kprocs = getprocs(KERN_PROC_ALL, 0, &count);
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
kproc = &kprocs[i];
|
||||
|
||||
@ -254,6 +258,8 @@ void ProcessList_goThroughEntries(ProcessList* this) {
|
||||
proc->user = UsersTable_getRef(this->usersTable, proc->st_uid);
|
||||
ProcessList_add((ProcessList*)this, proc);
|
||||
proc->comm = OpenBSDProcessList_readProcessName(opl->kd, kproc, &proc->basenameOffset);
|
||||
(void) localtime_r((time_t*) &kproc->p_ustart_sec, &date);
|
||||
strftime(proc->starttime_show, 7, ((proc->starttime_ctime > tv.tv_sec - 86400) ? "%R " : "%b%d "), &date);
|
||||
} else {
|
||||
if (settings->updateProcessNames) {
|
||||
free(proc->comm);
|
||||
|
@ -23,6 +23,7 @@ in the source distribution for its full text.
|
||||
#include <sys/sched.h>
|
||||
#include <uvm/uvmexp.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/swap.h>
|
||||
|
||||
#include <unistd.h>
|
||||
@ -34,6 +35,9 @@ in the source distribution for its full text.
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <kvm.h>
|
||||
#include <limits.h>
|
||||
|
||||
/*{
|
||||
#include "Action.h"
|
||||
@ -94,7 +98,7 @@ static int percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_
|
||||
|
||||
ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "Default",
|
||||
.name = "Main",
|
||||
.columns = "PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||
.sortKey = "PERCENT_CPU",
|
||||
},
|
||||
@ -302,6 +306,48 @@ void Platform_setTasksValues(Meter* this) {
|
||||
}
|
||||
|
||||
char* Platform_getProcessEnv(pid_t pid) {
|
||||
// TODO
|
||||
return NULL;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
char *env;
|
||||
char **ptr;
|
||||
int count;
|
||||
kvm_t *kt;
|
||||
struct kinfo_proc *kproc;
|
||||
size_t capacity = 4096, size = 0;
|
||||
|
||||
if ((kt = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if ((kproc = kvm_getprocs(kt, KERN_PROC_PID, pid,
|
||||
sizeof(struct kinfo_proc), &count)) == NULL) {\
|
||||
(void) kvm_close(kt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ptr = kvm_getenvv(kt, kproc, 0)) == NULL) {
|
||||
(void) kvm_close(kt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
env = xMalloc(capacity);
|
||||
for (char **p = ptr; *p; p++) {
|
||||
size_t len = strlen(*p) + 1;
|
||||
|
||||
if (size + len > capacity) {
|
||||
capacity *= 2;
|
||||
env = xRealloc(env, capacity);
|
||||
}
|
||||
|
||||
strlcpy(env + size, *p, len);
|
||||
size += len;
|
||||
}
|
||||
|
||||
if (size < 2 || env[size - 1] || env[size - 2]) {
|
||||
if (size + 2 < capacity)
|
||||
env = xRealloc(env, capacity + 2);
|
||||
env[size] = 0;
|
||||
env[size+1] = 0;
|
||||
}
|
||||
|
||||
(void) kvm_close(kt);
|
||||
return env;
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
import os, sys, string
|
||||
import os, sys, string, io
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
try:
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
from io import StringIO
|
||||
from io import StringIO
|
||||
|
||||
ANY=1
|
||||
COPY=2
|
||||
@ -17,7 +14,7 @@ COPYDEFINE=5
|
||||
state = ANY
|
||||
static = 0
|
||||
|
||||
file = open(sys.argv[1])
|
||||
file = io.open(sys.argv[1], "r", encoding="utf-8")
|
||||
name = sys.argv[1][:-2]
|
||||
|
||||
out = StringIO()
|
||||
@ -104,12 +101,12 @@ out.write( "#endif\n" )
|
||||
# This prevents a lot of recompilation during development
|
||||
out.seek(0)
|
||||
try:
|
||||
with open(name + ".h", "r") as orig:
|
||||
with io.open(name + ".h", "r", encoding="utf-8") as orig:
|
||||
origcontents = orig.readlines()
|
||||
except:
|
||||
origcontents = ""
|
||||
if origcontents != out.readlines():
|
||||
with open(name + ".h", "w") as new:
|
||||
with io.open(name + ".h", "w", encoding="utf-8") as new:
|
||||
print("Writing "+name+".h")
|
||||
new.write(out.getvalue())
|
||||
out.close()
|
||||
|
@ -35,6 +35,7 @@ in the source distribution for its full text.
|
||||
#include "Action.h"
|
||||
#include "BatteryMeter.h"
|
||||
#include "SignalsPanel.h"
|
||||
#include "SolarisProcess.h"
|
||||
#include <signal.h>
|
||||
#include <sys/mkdev.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -14,6 +14,7 @@ in the source distribution for its full text.
|
||||
#include "Action.h"
|
||||
#include "BatteryMeter.h"
|
||||
#include "SignalsPanel.h"
|
||||
#include "SolarisProcess.h"
|
||||
#include <signal.h>
|
||||
#include <sys/mkdev.h>
|
||||
#include <sys/proc.h>
|
||||
|
@ -170,14 +170,14 @@ void SolarisProcess_writeField(Process* this, RichString* str, ProcessField fiel
|
||||
long SolarisProcess_compare(const void* v1, const void* v2) {
|
||||
SolarisProcess *p1, *p2;
|
||||
Settings* settings = ((Process*)v1)->settings;
|
||||
if (settings->direction == 1) {
|
||||
if (settings->ss->direction == 1) {
|
||||
p1 = (SolarisProcess*)v1;
|
||||
p2 = (SolarisProcess*)v2;
|
||||
} else {
|
||||
p2 = (SolarisProcess*)v1;
|
||||
p1 = (SolarisProcess*)v2;
|
||||
}
|
||||
switch ((int) settings->sortKey) {
|
||||
switch ((int) settings->ss->sortKey) {
|
||||
case ZONEID:
|
||||
return (p1->zoneid - p2->zoneid);
|
||||
case PROJID:
|
||||
|
@ -31,7 +31,7 @@ const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(Si
|
||||
|
||||
ScreenDefaults Platform_defaultScreens[] = {
|
||||
{
|
||||
.name = "Default",
|
||||
.name = "Main",
|
||||
.columns = "PID LWPID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command",
|
||||
.sortKey = "PERCENT_CPU",
|
||||
},
|
||||
|
Reference in New Issue
Block a user