Fix CPU usage on OpenBSD

The current OpenBSD-specific CPU usage code is broken. The `cpu`
parameter of `Platform_setCPUValues` is an integer in the interval
[0, cpuCount], not [0, cpuCount-1]: Actual CPUs are numbered from
1, the “zero” CPU is a “virtual” one which represents the average
of actual CPUs (I guess it’s inherited from Linux’s `/proc/stats`).
This off-by-one error leads to random crashes.

Moreover, the displayed CPU usage is more detailed with system,
user and nice times.

I made the OpenBSD CPU code more similar to the Linux CPU code,
removing a few old bits from OpenBSD’s top(1). I think it will be
easier to understand, maintain and evolve.

I’d love some feedback from experienced OpenBSD people.

Committer note:
Cherry-picked from 9197adf57e04875fe7fd5b768bc5201d5def2548, with
modifications. The broken code described above is already fixed by
4bd878d9a1d530be6e9c2e6ef64dded302bc1062.
5 files changed
tree: 37dab453f16c6efa966619e2241eacff86028449
  1. .gitignore
  2. AUTHORS
  3. Action.c
  4. Action.h
  5. Affinity.c
  6. Affinity.h
  7. AffinityPanel.c
  8. AffinityPanel.h
  9. ArgScreen.c
  10. AvailableColumnsPanel.c
  11. AvailableColumnsPanel.h
  12. AvailableMetersPanel.c
  13. AvailableMetersPanel.h
  14. BatteryMeter.c
  15. BatteryMeter.h
  16. CONTRIBUTING.md
  17. COPYING
  18. CPUMeter.c
  19. CPUMeter.h
  20. CRT.c
  21. CRT.h
  22. CategoriesPanel.c
  23. CategoriesPanel.h
  24. ChangeLog
  25. CheckItem.c
  26. CheckItem.h
  27. ClockMeter.c
  28. ClockMeter.h
  29. ColorsPanel.c
  30. ColorsPanel.h
  31. ColumnsPanel.c
  32. ColumnsPanel.h
  33. DisplayOptionsPanel.c
  34. DisplayOptionsPanel.h
  35. EnvScreen.c
  36. EnvScreen.h
  37. FunctionBar.c
  38. FunctionBar.h
  39. Hashtable.c
  40. Hashtable.h
  41. Header.c
  42. Header.h
  43. HostnameMeter.c
  44. HostnameMeter.h
  45. IOUtils.c
  46. IncSet.c
  47. IncSet.h
  48. InfoScreen.c
  49. InfoScreen.h
  50. KStat.c
  51. ListItem.c
  52. ListItem.h
  53. LoadAverageMeter.c
  54. LoadAverageMeter.h
  55. MainPanel.c
  56. MainPanel.h
  57. Makefile.am
  58. MemoryMeter.c
  59. MemoryMeter.h
  60. Meter.c
  61. Meter.h
  62. MetersPanel.c
  63. MetersPanel.h
  64. NEWS
  65. Object.c
  66. Object.h
  67. OpenFilesScreen.c
  68. OpenFilesScreen.h
  69. Panel.c
  70. Panel.h
  71. Process.c
  72. Process.h
  73. ProcessList.c
  74. ProcessList.h
  75. README
  76. RichString.c
  77. RichString.h
  78. ScreenManager.c
  79. ScreenManager.h
  80. Settings.c
  81. Settings.h
  82. SignalsPanel.c
  83. SignalsPanel.h
  84. StringUtils.c
  85. StringUtils.h
  86. SwapMeter.c
  87. SwapMeter.h
  88. TESTPLAN
  89. TasksMeter.c
  90. TasksMeter.h
  91. TraceScreen.c
  92. TraceScreen.h
  93. UptimeMeter.c
  94. UptimeMeter.h
  95. UsersTable.c
  96. UsersTable.h
  97. Vector.c
  98. Vector.h
  99. XAlloc.c
  100. XAlloc.h
  101. aix/
  102. autogen.sh
  103. bsd/
  104. configure.ac
  105. cygwin/
  106. darwin/
  107. dragonflybsd/
  108. freebsd/
  109. htop.1.in
  110. htop.c
  111. htop.desktop
  112. htop.h
  113. htop.png
  114. interix/
  115. linux/
  116. local-curses.h
  117. openbsd/
  118. scripts/
  119. solaris/
  120. test_spec.lua
  121. unsupported/
README.md

Build Status PayPal donate

htop

by Hisham Muhammad hisham@gobolinux.org (2004 - 2016)

Introduction

This is htop, an interactive process viewer. It requires ncurses. It is developed primarily on Linux, but we also have code for running under FreeBSD and Mac OS X (help and testing are wanted for these platforms!)

This software has evolved considerably over the years, and is reasonably complete, but there is always room for improvement.

Comparison between htop and classic top

  • In htop you can scroll the list vertically and horizontally to see all processes and full command lines.
  • In top you are subject to a delay for each unassigned key you press (especially annoying when multi-key escape sequences are triggered by accident).
  • htop starts faster (top seems to collect data for a while before displaying anything).
  • In htop you don't need to type the process number to kill a process, in top you do.
  • In htop you don't need to type the process number or the priority value to renice a process, in top you do.
  • In htop you can kill multiple processes at once.
  • top is older, hence, more tested.

Compilation instructions

This program is distributed as a standard autotools-based package. See the INSTALL file for detailed instructions.

When compiling from a release tarball, run:

./configure && make

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)