Michael Witten ab3171d21d Process.{h,c}: Use integer types that are more portable
When building on a 32-bit system, the compiler warned that the
following line uses a constant whose value is the overflow result
of a compile-time computation:

  Process.c (line 109):   } else if (number < 10000 * ONE_M) {

Namely, this constant expression:

  10000 * ONE_M

was intended to produce the following value:

  10485760000

However, the result overflowed to produce:

   1895825408

The reason for this overflow is as follows:

  o The macros are expanded:

      10000 * (ONE_K * ONE_K)
      10000 * (1024L * 1024L)

  o The untyped constant expression "10000" is typed:

      10000U * (1024L * 1024L)

  o The parenthesized expression is evaluated:

      10000U * (1048576L)

  o The left operand ("10000U") is converted:

      10000L * (1048576L)

    Unbound by integer sizes, that last multiplication
    would produce the following value:

      10485760000

    However, on a 32-bit machine, where a long is 32 bits
    (really 31 bits when talking about positive numbers),
    the maximum value that can be computed is 2**31-1:

      2147483647

    Consequently, the computation overflows.

  o The compiler produces a long int value that is the
    the result of overflow (10485760000 % 2**31):

      1895825408L

    Actually, I think this overflow is implementation-defined,
    so it's not even a portable description of what happens.

The solution is to use a long long int (or, even better,
an unsigned long long int) type for the constant expression;
the C standard mandates a sufficiently large maximum value
for such types.

Hence, the following change is made to the bad line:

  -   } else if (number < 10000 * ONE_M) {
  +   } else if (number < 10000ULL * ONE_M) {

However, the whole line is now patently silly, because the
variable "number" is typed "unsigned long", and so it will
always be less than the constant expression (the compiler
will warn about this, too).

Hence, "number" must be typed "unsigned long long"; however,
this necessitates changing all of the string formats from
something like "%lu" to something like "%llu".

Et voila! This commit is born.

Then, for the sake of completeness, the declared types of the
constant-expression macros are updated:

  o ONE_K is made unsigned (a "UL" instead of "L")
  o ONE_T is computed by introducing "1ULL *"
  o Similar changes are made for ONE_DECIMAL_{K,T}

Also, a non-portable overflow-conversion to a signed value
has been replaced with a portable comparison:

  -   if ((long long) number == -1LL) {
  +   if (number == ULLONG_MAX) {

It might be worth reviewing the rest of the code for other
cases where overflows are not handled correctly; even at
runtime, it's often necessary to check for overflow unless
such behavior is expected (especially for signed integer
values, for which overflow has implementation-defined
behavior).
2020-09-29 15:47:52 +00:00
2020-09-29 10:44:42 +02:00
2020-09-18 12:28:40 +02:00
2020-09-03 11:58:58 -05:00
2020-09-29 10:44:42 +02:00
2020-09-18 12:28:40 +02:00
2020-09-18 12:28:40 +02:00
2020-09-24 20:14:17 +02:00
2006-03-04 18:16:49 +00:00
2020-09-03 11:58:58 -05:00
2020-09-03 11:58:58 -05:00
2020-08-21 10:37:33 +02:00
2020-09-18 12:28:40 +02:00
2020-09-29 10:44:42 +02:00
2020-09-03 11:58:58 -05:00
2020-09-03 11:58:58 -05:00
2014-04-09 14:47:58 -03:00
2020-09-18 12:28:40 +02:00
2020-09-24 20:14:17 +02:00
2020-09-18 12:28:40 +02:00
2020-09-18 12:28:40 +02:00
2020-09-24 20:14:17 +02:00
2020-09-17 22:04:11 +02:00
2020-08-21 10:37:33 +02:00
2020-09-03 11:58:58 -05:00
2020-09-18 12:22:18 +02:00
2014-02-03 09:11:39 -02:00
2020-09-24 20:14:17 +02:00
2020-09-24 20:14:17 +02:00
2020-09-18 12:28:40 +02:00
2020-08-21 10:37:33 +02:00
2020-08-21 10:37:33 +02:00
2020-09-17 21:43:05 +02:00
2020-09-03 11:58:58 -05:00
2020-09-18 12:28:40 +02:00
2020-09-29 10:44:42 +02:00
2020-09-24 20:14:17 +02:00
2020-09-18 12:28:40 +02:00

htop

CI Coverity Scan Build Status Mailing List IRC #htop Github Release Download

Introduction

htop is a cross-platform interactive process viewer.

htop allows scrolling the list of processes vertically and horizontally to see their full command lines and related information like memory and CPU consumption.

The information displayed is configurable through a graphical setup and can be sorted and filtered interactively.

Tasks related to processes (e.g. killing and renicing) can be done without entering their PIDs.

Running htop requires ncurses libraries (typically named libncursesw*).

For more information and details on how to contribute to htop visit htop.dev.

Build instructions

This program is distributed as a standard GNU autotools-based package.

Compiling htop requires the header files for ncurses (libncursesw*-dev). Install these and other required packages for C development from your package manager.

Then, when compiling from a release tarball, run:

./configure && make

Alternatively, for compiling sources downloaded from the Git repository (git clone or downloads from Github releases), install the header files for ncurses (libncursesw*-dev) and other required development packages from your distribution's package manager. Then 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.

Support

If you have trouble running htop please consult your Operating System / Linux distribution documentation for getting support and filing bugs.

Bugs, development feedback

We have a development mailing list. Feel free to subscribe for release announcements or asking questions on the development of htop.

You can also join our IRC channel #htop on freenode and talk to the developers there.

If you have found an issue with the source of htop, please check whether this has already been reported in our Github issue tracker. If not, please file a new issue describing the problem you have found, the location in the source code you are referring to and a possible fix.

History

htop was invented, developed and maintained by Hisham Muhammad from 2004 to 2019. His legacy repository has been archived to preserve the history.

In 2020 a team took over the development amicably and continues to maintain htop collaboratively.

License

GNU General Public License, version 2 (GPL-2.0)

Description
htop - an interactive process viewer
Readme 6 MiB
Languages
C 93%
Roff 2.3%
M4 2.3%
Lua 1.5%
Makefile 0.8%