mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-15 21:44:36 +03:00
Compare commits
145 Commits
Author | SHA1 | Date | |
---|---|---|---|
d73783d6db | |||
89b7c4c9f9 | |||
78aefc2a99 | |||
697c502b7e | |||
171aa0faaa | |||
ddfacb8694 | |||
5beef3e737 | |||
27a18830d5 | |||
b98a4f8d56 | |||
55e073a455 | |||
915b558bbe | |||
550100327b | |||
9dc964bb42 | |||
ea4282784d | |||
1c3c149d20 | |||
42c0493021 | |||
1284ab4835 | |||
07496eafb0 | |||
e7a8d14cbd | |||
21cb1c4d59 | |||
e64269df2c | |||
d8dfbbd37c | |||
afa3fe4af1 | |||
2ef70ad7f6 | |||
2977414d54 | |||
696f79fe50 | |||
4374a267be | |||
3e70de64b3 | |||
3f9f52fd29 | |||
dfa62506b7 | |||
731b4003a2 | |||
30c5004cbb | |||
9d3a1d4981 | |||
60cfa2edce | |||
604744f68d | |||
13fe58f54a | |||
e785693ef9 | |||
4cf74de1f1 | |||
0a5890d332 | |||
2128edfba2 | |||
d1c833fe95 | |||
868b0b3574 | |||
04871a2d04 | |||
b7248f6cb8 | |||
74afca7bc1 | |||
2a13e15ad0 | |||
8ac8542b6e | |||
f75a8bc3a1 | |||
d520199e62 | |||
9d8d87e1d5 | |||
57c1538887 | |||
9eb52d5932 | |||
970885edc3 | |||
ae1816e563 | |||
53732ab0bb | |||
8932efece9 | |||
d23627fda9 | |||
4c846921a6 | |||
c5e789db1b | |||
eb94c4f9c9 | |||
8361c6c1ae | |||
07f934ccfb | |||
6f751d5929 | |||
e26a2cf431 | |||
d527bc9132 | |||
dadcb87ad0 | |||
754c0d6bb9 | |||
9f4a4faab9 | |||
a710deeaa7 | |||
466d6f99e2 | |||
1601931bbf | |||
41f9c0ab77 | |||
e28d022716 | |||
d5ac75a5c7 | |||
2ba7d5ff36 | |||
3d99c306b9 | |||
3d3474b3fc | |||
94ad111391 | |||
976fa3b121 | |||
61227793de | |||
e6ded48d1a | |||
87c992739b | |||
29e1fcfa05 | |||
29983ff83a | |||
36b7f57200 | |||
c5fe142256 | |||
691b7dd5af | |||
ad0f9c58bf | |||
a8d0f2a7fe | |||
e6596cbd69 | |||
40c9f89971 | |||
09ad8067f4 | |||
bda3ee2b81 | |||
bdb015ffa3 | |||
80a515abcc | |||
5000cefc13 | |||
bf7d98e7ac | |||
c096712b8d | |||
be82448bd5 | |||
68c00b9cdb | |||
3c8d586a1c | |||
3869c43393 | |||
fcca4c2f2d | |||
dd88510dcd | |||
43ffdb0eda | |||
bf395e10c5 | |||
8f259bc5e1 | |||
38e6136b82 | |||
589b0733d9 | |||
c9b58c7fbe | |||
ca06e68037 | |||
a516e0852e | |||
3f805cf347 | |||
556d7c03e8 | |||
0925c54caa | |||
d0f5b61aa5 | |||
284f8c5e0b | |||
11b65a2861 | |||
b85b718e69 | |||
7891cdc552 | |||
b9fdf1c2a1 | |||
2844429f15 | |||
3834f2a68f | |||
343c2e58be | |||
fd2c4f5ddd | |||
7f95ed8528 | |||
9579d9b7aa | |||
0580dbb202 | |||
c0c2bb98a2 | |||
9b30870eec | |||
25c945e2ef | |||
f94934472f | |||
becd33795c | |||
74f99e3693 | |||
e1f4645bd1 | |||
0afd0fe572 | |||
ff336b652c | |||
58a59c11f4 | |||
3f806368e0 | |||
4855d92469 | |||
b81bb9038c | |||
1f2f567ca1 | |||
393330239e | |||
d2c34259b4 | |||
858ad8029d |
51
.github/workflows/build_release.yml
vendored
Normal file
51
.github/workflows/build_release.yml
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
name: Build Source Release
|
||||||
|
|
||||||
|
# Trigger whenever a release is created
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- created
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: archive
|
||||||
|
id: archive
|
||||||
|
run: |
|
||||||
|
VERSION=${{ github.event.release.tag_name }}
|
||||||
|
PKGNAME="htop-$VERSION"
|
||||||
|
SHASUM=$PKGNAME.tar.xz.sha256
|
||||||
|
autoreconf -i
|
||||||
|
mkdir -p /tmp/$PKGNAME
|
||||||
|
mv * /tmp/$PKGNAME
|
||||||
|
mv /tmp/$PKGNAME .
|
||||||
|
TARBALL=$PKGNAME.tar.xz
|
||||||
|
tar cJf $TARBALL $PKGNAME
|
||||||
|
sha256sum $TARBALL > $SHASUM
|
||||||
|
echo "::set-output name=tarball::$TARBALL"
|
||||||
|
echo "::set-output name=shasum::$SHASUM"
|
||||||
|
- name: upload tarball
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ github.event.release.upload_url }}
|
||||||
|
asset_path: ./${{ steps.archive.outputs.tarball }}
|
||||||
|
asset_name: ${{ steps.archive.outputs.tarball }}
|
||||||
|
asset_content_type: application/gzip
|
||||||
|
|
||||||
|
- name: upload shasum
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ github.event.release.upload_url }}
|
||||||
|
asset_path: ./${{ steps.archive.outputs.shasum }}
|
||||||
|
asset_name: ${{ steps.archive.outputs.shasum }}
|
||||||
|
asset_content_type: text/plain
|
@ -9,7 +9,8 @@ os:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- ./autogen.sh
|
- ./autogen.sh
|
||||||
# clang might warn about C11 generic selections in isnan()
|
- ./configure --enable-werror
|
||||||
- CFLAGS=-Wno-c11-extensions ./configure --enable-werror
|
|
||||||
- make -k
|
- make -k
|
||||||
- CFLAGS=-Wno-c11-extensions make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
|
- make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
|
||||||
|
- sudo make install
|
||||||
|
- make installcheck
|
||||||
|
4
Action.c
4
Action.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Action.c
|
htop - Action.c
|
||||||
(C) 2015 Hisham H. Muhammad
|
(C) 2015 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -519,7 +519,7 @@ static Htop_Reaction actionHelp(State* st) {
|
|||||||
int line = 0;
|
int line = 0;
|
||||||
|
|
||||||
mvaddstr(line++, 0, "htop " VERSION " - " COPYRIGHT);
|
mvaddstr(line++, 0, "htop " VERSION " - " COPYRIGHT);
|
||||||
mvaddstr(line++, 0, "Released under the GNU GPLv2. See 'man' page for more info.");
|
mvaddstr(line++, 0, "Released under the GNU GPLv2+. See 'man' page for more info.");
|
||||||
|
|
||||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||||
line++;
|
line++;
|
||||||
|
2
Action.h
2
Action.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Action.h
|
htop - Action.h
|
||||||
(C) 2015 Hisham H. Muhammad
|
(C) 2015 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
htop - Affinity.c
|
htop - Affinity.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -63,9 +63,9 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
|
|||||||
Affinity_add(affinity, i);
|
Affinity_add(affinity, i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unsigned int id;
|
int id;
|
||||||
hwloc_bitmap_foreach_begin(id, cpuset);
|
hwloc_bitmap_foreach_begin(id, cpuset)
|
||||||
Affinity_add(affinity, id);
|
Affinity_add(affinity, (unsigned)id);
|
||||||
hwloc_bitmap_foreach_end();
|
hwloc_bitmap_foreach_end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
htop - Affinity.h
|
htop - Affinity.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - AffinityPanel.c
|
htop - AffinityPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -425,9 +425,9 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
|
|||||||
Affinity* affinity = Affinity_new(pl);
|
Affinity* affinity = Affinity_new(pl);
|
||||||
|
|
||||||
#ifdef HAVE_LIBHWLOC
|
#ifdef HAVE_LIBHWLOC
|
||||||
unsigned int i;
|
int i;
|
||||||
hwloc_bitmap_foreach_begin(i, this->workCpuset)
|
hwloc_bitmap_foreach_begin(i, this->workCpuset)
|
||||||
Affinity_add(affinity, i);
|
Affinity_add(affinity, (unsigned)i);
|
||||||
hwloc_bitmap_foreach_end();
|
hwloc_bitmap_foreach_end();
|
||||||
#else
|
#else
|
||||||
for (int i = 0; i < Vector_size(this->cpuids); i++) {
|
for (int i = 0; i < Vector_size(this->cpuids); i++) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - AffinityPanel.h
|
htop - AffinityPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - AvailableColumnsPanel.c
|
htop - AvailableColumnsPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - AvailableColumnsPanel.h
|
htop - AvailableColumnsPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - AvailableMetersPanel.c
|
htop - AvailableMetersPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - AvailableMetersPanel.h
|
htop - AvailableMetersPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - BatteryMeter.c
|
htop - BatteryMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
|
|
||||||
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
|
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - BatteryMeter.h
|
htop - BatteryMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
|
|
||||||
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
|
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).
|
||||||
|
17
CPUMeter.c
17
CPUMeter.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - CPUMeter.c
|
htop - CPUMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ static void CPUMeter_init(Meter* this) {
|
|||||||
// Custom uiName runtime logic to include the param (processor)
|
// Custom uiName runtime logic to include the param (processor)
|
||||||
static void CPUMeter_getUiName(const Meter* this, char* buffer, size_t length) {
|
static void CPUMeter_getUiName(const Meter* this, char* buffer, size_t length) {
|
||||||
if (this->param > 0)
|
if (this->param > 0)
|
||||||
xSnprintf(buffer, sizeof(length), "%s %u", Meter_uiName(this), this->param);
|
xSnprintf(buffer, length, "%s %u", Meter_uiName(this), this->param);
|
||||||
else
|
else
|
||||||
xSnprintf(buffer, sizeof(length), "%s", Meter_uiName(this));
|
xSnprintf(buffer, length, "%s", Meter_uiName(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CPUMeter_updateValues(Meter* this) {
|
static void CPUMeter_updateValues(Meter* this) {
|
||||||
@ -381,6 +381,7 @@ const MeterClass AllCPUs2Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "AllCPUs2",
|
.name = "AllCPUs2",
|
||||||
@ -401,6 +402,7 @@ const MeterClass LeftCPUsMeter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "LeftCPUs",
|
.name = "LeftCPUs",
|
||||||
@ -421,6 +423,7 @@ const MeterClass RightCPUsMeter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "RightCPUs",
|
.name = "RightCPUs",
|
||||||
@ -441,6 +444,7 @@ const MeterClass LeftCPUs2Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "LeftCPUs2",
|
.name = "LeftCPUs2",
|
||||||
@ -461,6 +465,7 @@ const MeterClass RightCPUs2Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "RightCPUs2",
|
.name = "RightCPUs2",
|
||||||
@ -481,6 +486,7 @@ const MeterClass AllCPUs4Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "AllCPUs4",
|
.name = "AllCPUs4",
|
||||||
@ -501,6 +507,7 @@ const MeterClass LeftCPUs4Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "LeftCPUs4",
|
.name = "LeftCPUs4",
|
||||||
@ -521,6 +528,7 @@ const MeterClass RightCPUs4Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "RightCPUs4",
|
.name = "RightCPUs4",
|
||||||
@ -541,6 +549,7 @@ const MeterClass AllCPUs8Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "AllCPUs8",
|
.name = "AllCPUs8",
|
||||||
@ -561,6 +570,7 @@ const MeterClass LeftCPUs8Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "LeftCPUs8",
|
.name = "LeftCPUs8",
|
||||||
@ -581,6 +591,7 @@ const MeterClass RightCPUs8Meter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = AllCPUsMeter_updateValues,
|
.updateValues = AllCPUsMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.total = 100.0,
|
.total = 100.0,
|
||||||
.attributes = CPUMeter_attributes,
|
.attributes = CPUMeter_attributes,
|
||||||
.name = "RightCPUs8",
|
.name = "RightCPUs8",
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - CPUMeter.h
|
htop - CPUMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
101
CRT.c
101
CRT.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - CRT.c
|
htop - CRT.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -21,14 +21,22 @@ in the source distribution for its full text.
|
|||||||
#include "ProvideCurses.h"
|
#include "ProvideCurses.h"
|
||||||
#include "XUtils.h"
|
#include "XUtils.h"
|
||||||
|
|
||||||
#ifdef HAVE_EXECINFO_H
|
|
||||||
#include <execinfo.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(NDEBUG) && defined(HAVE_MEMFD_CREATE)
|
#if !defined(NDEBUG) && defined(HAVE_MEMFD_CREATE)
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_LIBUNWIND_H) && defined(HAVE_LIBUNWIND)
|
||||||
|
# define PRINT_BACKTRACE
|
||||||
|
# define UNW_LOCAL_ONLY
|
||||||
|
# include <libunwind.h>
|
||||||
|
# if defined(HAVE_DLADDR)
|
||||||
|
# include <dlfcn.h>
|
||||||
|
# endif
|
||||||
|
#elif defined(HAVE_EXECINFO_H)
|
||||||
|
# define PRINT_BACKTRACE
|
||||||
|
# include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define ColorIndex(i,j) ((7-(i))*8+(j))
|
#define ColorIndex(i,j) ((7-(i))*8+(j))
|
||||||
|
|
||||||
@ -138,7 +146,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
|||||||
[PROCESS_GIGABYTES] = ColorPair(Green, Black),
|
[PROCESS_GIGABYTES] = ColorPair(Green, Black),
|
||||||
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan, Black),
|
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan, Black),
|
||||||
[PROCESS_TREE] = ColorPair(Cyan, Black),
|
[PROCESS_TREE] = ColorPair(Cyan, Black),
|
||||||
[PROCESS_R_STATE] = ColorPair(Green, Black),
|
[PROCESS_RUN_STATE] = ColorPair(Green, Black),
|
||||||
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
|
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
|
||||||
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
|
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
|
||||||
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
|
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
|
||||||
@ -240,7 +248,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
|||||||
[PROCESS_GIGABYTES] = A_BOLD,
|
[PROCESS_GIGABYTES] = A_BOLD,
|
||||||
[PROCESS_BASENAME] = A_BOLD,
|
[PROCESS_BASENAME] = A_BOLD,
|
||||||
[PROCESS_TREE] = A_BOLD,
|
[PROCESS_TREE] = A_BOLD,
|
||||||
[PROCESS_R_STATE] = A_BOLD,
|
[PROCESS_RUN_STATE] = A_BOLD,
|
||||||
[PROCESS_D_STATE] = A_BOLD,
|
[PROCESS_D_STATE] = A_BOLD,
|
||||||
[PROCESS_HIGH_PRIORITY] = A_BOLD,
|
[PROCESS_HIGH_PRIORITY] = A_BOLD,
|
||||||
[PROCESS_LOW_PRIORITY] = A_DIM,
|
[PROCESS_LOW_PRIORITY] = A_DIM,
|
||||||
@ -342,7 +350,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
|||||||
[PROCESS_GIGABYTES] = ColorPair(Green, White),
|
[PROCESS_GIGABYTES] = ColorPair(Green, White),
|
||||||
[PROCESS_BASENAME] = ColorPair(Blue, White),
|
[PROCESS_BASENAME] = ColorPair(Blue, White),
|
||||||
[PROCESS_TREE] = ColorPair(Green, White),
|
[PROCESS_TREE] = ColorPair(Green, White),
|
||||||
[PROCESS_R_STATE] = ColorPair(Green, White),
|
[PROCESS_RUN_STATE] = ColorPair(Green, White),
|
||||||
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, White),
|
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, White),
|
||||||
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, White),
|
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, White),
|
||||||
[PROCESS_LOW_PRIORITY] = ColorPair(Green, White),
|
[PROCESS_LOW_PRIORITY] = ColorPair(Green, White),
|
||||||
@ -444,7 +452,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
|||||||
[PROCESS_GIGABYTES] = ColorPair(Green, Black),
|
[PROCESS_GIGABYTES] = ColorPair(Green, Black),
|
||||||
[PROCESS_BASENAME] = ColorPair(Green, Black),
|
[PROCESS_BASENAME] = ColorPair(Green, Black),
|
||||||
[PROCESS_TREE] = ColorPair(Blue, Black),
|
[PROCESS_TREE] = ColorPair(Blue, Black),
|
||||||
[PROCESS_R_STATE] = ColorPair(Green, Black),
|
[PROCESS_RUN_STATE] = ColorPair(Green, Black),
|
||||||
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
|
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
|
||||||
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
|
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
|
||||||
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
|
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
|
||||||
@ -546,7 +554,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
|||||||
[PROCESS_GIGABYTES] = ColorPair(Green, Blue),
|
[PROCESS_GIGABYTES] = ColorPair(Green, Blue),
|
||||||
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan, Blue),
|
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan, Blue),
|
||||||
[PROCESS_TREE] = ColorPair(Cyan, Blue),
|
[PROCESS_TREE] = ColorPair(Cyan, Blue),
|
||||||
[PROCESS_R_STATE] = ColorPair(Green, Blue),
|
[PROCESS_RUN_STATE] = ColorPair(Green, Blue),
|
||||||
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Blue),
|
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Blue),
|
||||||
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Blue),
|
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Blue),
|
||||||
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Blue),
|
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Blue),
|
||||||
@ -652,7 +660,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
|
|||||||
[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue, Black),
|
[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue, Black),
|
||||||
[PROCESS_COMM] = ColorPair(Magenta, Black),
|
[PROCESS_COMM] = ColorPair(Magenta, Black),
|
||||||
[PROCESS_THREAD_COMM] = ColorPair(Yellow, Black),
|
[PROCESS_THREAD_COMM] = ColorPair(Yellow, Black),
|
||||||
[PROCESS_R_STATE] = ColorPair(Green, Black),
|
[PROCESS_RUN_STATE] = ColorPair(Green, Black),
|
||||||
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
|
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
|
||||||
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
|
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
|
||||||
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
|
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
|
||||||
@ -772,6 +780,8 @@ static void dumpStderr(void) {
|
|||||||
|
|
||||||
fsync(STDERR_FILENO);
|
fsync(STDERR_FILENO);
|
||||||
dup2(stderrRedirectBackupFd, STDERR_FILENO);
|
dup2(stderrRedirectBackupFd, STDERR_FILENO);
|
||||||
|
close(stderrRedirectBackupFd);
|
||||||
|
stderrRedirectBackupFd = -1;
|
||||||
lseek(stderrRedirectNewFd, 0, SEEK_SET);
|
lseek(stderrRedirectNewFd, 0, SEEK_SET);
|
||||||
|
|
||||||
bool header = false;
|
bool header = false;
|
||||||
@ -886,6 +896,10 @@ void CRT_init(const Settings* settings, bool allowUnicode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (termType && (String_startsWith(termType, "xterm") || String_eq(termType, "vt220"))) {
|
if (termType && (String_startsWith(termType, "xterm") || String_eq(termType, "vt220"))) {
|
||||||
|
#ifdef HTOP_NETBSD
|
||||||
|
#define define_key(s_, k_) define_key((char*)s_, k_)
|
||||||
|
IGNORE_WCASTQUAL_BEGIN
|
||||||
|
#endif
|
||||||
define_key("\033[H", KEY_HOME);
|
define_key("\033[H", KEY_HOME);
|
||||||
define_key("\033[F", KEY_END);
|
define_key("\033[F", KEY_END);
|
||||||
define_key("\033[7~", KEY_HOME);
|
define_key("\033[7~", KEY_HOME);
|
||||||
@ -906,6 +920,10 @@ void CRT_init(const Settings* settings, bool allowUnicode) {
|
|||||||
sequence[1] = c;
|
sequence[1] = c;
|
||||||
define_key(sequence, KEY_ALT('A' + (c - 'a')));
|
define_key(sequence, KEY_ALT('A' + (c - 'a')));
|
||||||
}
|
}
|
||||||
|
#ifdef HTOP_NETBSD
|
||||||
|
IGNORE_WCASTQUAL_END
|
||||||
|
#undef define_key
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CRT_installSignalHandlers();
|
CRT_installSignalHandlers();
|
||||||
@ -998,6 +1016,59 @@ void CRT_setColors(int colorScheme) {
|
|||||||
CRT_colors = CRT_colorSchemes[colorScheme];
|
CRT_colors = CRT_colorSchemes[colorScheme];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PRINT_BACKTRACE
|
||||||
|
static void print_backtrace(void) {
|
||||||
|
#if defined(HAVE_LIBUNWIND_H) && defined(HAVE_LIBUNWIND)
|
||||||
|
unw_context_t context;
|
||||||
|
unw_getcontext(&context);
|
||||||
|
|
||||||
|
unw_cursor_t cursor;
|
||||||
|
unw_init_local(&cursor, &context);
|
||||||
|
|
||||||
|
unsigned int item = 0;
|
||||||
|
|
||||||
|
while (unw_step(&cursor) > 0) {
|
||||||
|
unw_word_t pc;
|
||||||
|
unw_get_reg(&cursor, UNW_REG_IP, &pc);
|
||||||
|
if (pc == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
char symbolName[256] = "?";
|
||||||
|
unw_word_t offset = 0;
|
||||||
|
unw_get_proc_name(&cursor, symbolName, sizeof(symbolName), &offset);
|
||||||
|
|
||||||
|
unw_proc_info_t pip;
|
||||||
|
pip.unwind_info = NULL;
|
||||||
|
|
||||||
|
const char* fname = "?";
|
||||||
|
const void* ptr = 0;
|
||||||
|
if (unw_get_proc_info(&cursor, &pip) == 0) {
|
||||||
|
ptr = (const void*)(pip.start_ip + offset);
|
||||||
|
|
||||||
|
#ifdef HAVE_DLADDR
|
||||||
|
Dl_info dlinfo;
|
||||||
|
if (dladdr(ptr, &dlinfo) && dlinfo.dli_fname && *dlinfo.dli_fname)
|
||||||
|
fname = dlinfo.dli_fname;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* frame = "";
|
||||||
|
if (unw_is_signal_frame(&cursor) > 0)
|
||||||
|
frame = "{signal frame}";
|
||||||
|
|
||||||
|
fprintf(stderr, "%2u: %#14lx %s (%s+%#lx) [%p]%s%s\n", item++, pc, fname, symbolName, offset, ptr, frame ? " " : "", frame);
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_EXECINFO_H)
|
||||||
|
void* backtraceArray[256];
|
||||||
|
|
||||||
|
size_t size = backtrace(backtraceArray, ARRAYSIZE(backtraceArray));
|
||||||
|
backtrace_symbols_fd(backtraceArray, size, STDERR_FILENO);
|
||||||
|
#else
|
||||||
|
#error No implementation for print_backtrace()!
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CRT_handleSIGSEGV(int signal) {
|
void CRT_handleSIGSEGV(int signal) {
|
||||||
CRT_done();
|
CRT_done();
|
||||||
|
|
||||||
@ -1012,7 +1083,7 @@ void CRT_handleSIGSEGV(int signal) {
|
|||||||
" - Likely steps to reproduce (How did it happen?)\n"
|
" - Likely steps to reproduce (How did it happen?)\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef HAVE_EXECINFO_H
|
#ifdef PRINT_BACKTRACE
|
||||||
fprintf(stderr, " - Backtrace of the issue (see below)\n");
|
fprintf(stderr, " - Backtrace of the issue (see below)\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1038,16 +1109,14 @@ void CRT_handleSIGSEGV(int signal) {
|
|||||||
Settings_write(CRT_crashSettings, true);
|
Settings_write(CRT_crashSettings, true);
|
||||||
fprintf(stderr, "\n\n");
|
fprintf(stderr, "\n\n");
|
||||||
|
|
||||||
#ifdef HAVE_EXECINFO_H
|
#ifdef PRINT_BACKTRACE
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Backtrace information:\n"
|
"Backtrace information:\n"
|
||||||
"----------------------\n"
|
"----------------------\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
void* backtraceArray[256];
|
print_backtrace();
|
||||||
|
|
||||||
size_t size = backtrace(backtraceArray, ARRAYSIZE(backtraceArray));
|
|
||||||
backtrace_symbols_fd(backtraceArray, size, STDERR_FILENO);
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n"
|
"\n"
|
||||||
"To make the above information more practical to work with, "
|
"To make the above information more practical to work with, "
|
||||||
|
10
CRT.h
10
CRT.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - CRT.h
|
htop - CRT.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ typedef enum ColorElements_ {
|
|||||||
PROCESS_MEGABYTES,
|
PROCESS_MEGABYTES,
|
||||||
PROCESS_GIGABYTES,
|
PROCESS_GIGABYTES,
|
||||||
PROCESS_TREE,
|
PROCESS_TREE,
|
||||||
PROCESS_R_STATE,
|
PROCESS_RUN_STATE,
|
||||||
PROCESS_D_STATE,
|
PROCESS_D_STATE,
|
||||||
PROCESS_BASENAME,
|
PROCESS_BASENAME,
|
||||||
PROCESS_HIGH_PRIORITY,
|
PROCESS_HIGH_PRIORITY,
|
||||||
@ -147,9 +147,9 @@ void CRT_fatalError(const char* note) ATTR_NORETURN;
|
|||||||
|
|
||||||
void CRT_handleSIGSEGV(int signal) ATTR_NORETURN;
|
void CRT_handleSIGSEGV(int signal) ATTR_NORETURN;
|
||||||
|
|
||||||
#define KEY_WHEELUP KEY_F(20)
|
#define KEY_WHEELUP KEY_F(30)
|
||||||
#define KEY_WHEELDOWN KEY_F(21)
|
#define KEY_WHEELDOWN KEY_F(31)
|
||||||
#define KEY_RECLICK KEY_F(22)
|
#define KEY_RECLICK KEY_F(32)
|
||||||
#define KEY_ALT(x) (KEY_F(64 - 26) + ((x) - 'A'))
|
#define KEY_ALT(x) (KEY_F(64 - 26) + ((x) - 'A'))
|
||||||
|
|
||||||
extern const char* CRT_degreeSign;
|
extern const char* CRT_degreeSign;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - CategoriesPanel.c
|
htop - CategoriesPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ static void CategoriesPanel_delete(Object* object) {
|
|||||||
|
|
||||||
static void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
|
static void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
|
||||||
size_t columns = HeaderLayout_getColumns(this->scr->header->headerLayout);
|
size_t columns = HeaderLayout_getColumns(this->scr->header->headerLayout);
|
||||||
MetersPanel** meterPanels = xMallocArray(columns, sizeof(MetersPanel));
|
MetersPanel** meterPanels = xMallocArray(columns, sizeof(MetersPanel*));
|
||||||
|
|
||||||
for (size_t i = 0; i < columns; i++) {
|
for (size_t i = 0; i < columns; i++) {
|
||||||
char titleBuffer[32];
|
char titleBuffer[32];
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - CategoriesPanel.h
|
htop - CategoriesPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
103
ChangeLog
103
ChangeLog
@ -1,5 +1,37 @@
|
|||||||
What's new in version 3.1.0
|
What's new in version 3.1.2
|
||||||
|
|
||||||
|
* Bugfix for crash when storing modified settings at exit
|
||||||
|
* Generate xz-compressed source tarball (with configure) using github actions
|
||||||
|
* Allow -u UID with numerical value as argument
|
||||||
|
* Added documentation for obsolete/state libraries/program files highlighting
|
||||||
|
* Some obsolete/stale library highlighting refinements
|
||||||
|
* Column width issues resolved
|
||||||
|
* Dynamic UID column sizing improved
|
||||||
|
* Discard stale information from Disk and Network I/O meters
|
||||||
|
* Refined Linux kernel thread detection
|
||||||
|
* Reworked process state handling
|
||||||
|
* New CCGROUP column showing abbreviated cgroup name
|
||||||
|
* New OFFSET column in the list of open files screen
|
||||||
|
|
||||||
|
What's new in version 3.1.1
|
||||||
|
|
||||||
|
* Update license headers to explicitly say GPLv2+
|
||||||
|
* Document minimum version for libcap (thanks to James Brown)
|
||||||
|
* Fix mouse wheel collision with autogroups nice adjustment
|
||||||
|
* Adjust Makefile.am macro definitions for older automake versions
|
||||||
|
* Ensure consistent reporting of MemoryMeter 'used' memory
|
||||||
|
* Report hugepage memory as real and used memory (as before)
|
||||||
|
* Handle procExeDeleted, usesDeletedLib without mergedCommandline mode
|
||||||
|
* Validate meter configuration before proceeding beyond htoprc parsing
|
||||||
|
* Properly release memory on partially read configuration
|
||||||
|
* Handle interrupted sampling from within libpcp PDU transfers
|
||||||
|
* On Linux, provide O_PATH value if not defined
|
||||||
|
* On Linux, always compute procExeDeleted if already set
|
||||||
|
* Workaround for Rosetta 2 on Darwin (thanks to Alexander Momchilov)
|
||||||
|
* Fix FreeBSD cmdline memory leak in Process_updateCmdline, and
|
||||||
|
* Plug a Disk I/O meter memory leak on FreeBSD (thanks to Ximalas)
|
||||||
|
|
||||||
|
What's new in version 3.1.0
|
||||||
|
|
||||||
* Updated COPYING file to remove the PLPA exemption (appendix 2)
|
* Updated COPYING file to remove the PLPA exemption (appendix 2)
|
||||||
With this change the license is now GPLv2 without any additional wording.
|
With this change the license is now GPLv2 without any additional wording.
|
||||||
@ -26,19 +58,20 @@ What's new in version 3.1.0
|
|||||||
Moving this column to be handled as a platform-independently available
|
Moving this column to be handled as a platform-independently available
|
||||||
information simplifies the markup of the command line.
|
information simplifies the markup of the command line.
|
||||||
* Introduce configuration file versioning and config_reader_min_version
|
* Introduce configuration file versioning and config_reader_min_version
|
||||||
Starting with this version the configuration file contains an version
|
Starting with this version the configuration file contains a version
|
||||||
identifying the minimum version of the configuration parser needed to
|
identifying the minimum version of the configuration parser needed to
|
||||||
fully understand the configuration file format.
|
fully understand the configuration file format.
|
||||||
Old configuration file formats are automatically upgraded on startup.
|
Old configuration file formats are automatically upgraded when
|
||||||
|
saving the config file (htoprc).
|
||||||
* Make the configuration parser friendlier to users (thanks to Bart Bakker)
|
* Make the configuration parser friendlier to users (thanks to Bart Bakker)
|
||||||
With this change only settings that cannot be parsed properly are
|
With this change only settings that cannot be parsed properly are
|
||||||
reset to their defaults.
|
reset to their defaults.
|
||||||
* Improve default display for systems with many CPUs
|
* Improve default display for systems with many CPUs
|
||||||
* Add the process ELAPSED time column
|
* Add the process ELAPSED time column
|
||||||
* Improve the process STATE column sorting
|
* Improve the process STATE column sorting
|
||||||
* Reworked handling resize and redrawing of the UI
|
* Reworked handling resize and redrawing of the UI
|
||||||
* Fixed an issue where the LED meter mode could overflow allotted space
|
* Fixed an issue where the LED meter mode could overflow allotted space
|
||||||
* Allow text mode Meters to span empty neighbors to the right
|
* Allow text mode Meters to span empty neighbors to the right
|
||||||
* Rescale graph meters when value of total changes
|
* Rescale graph meters when value of total changes
|
||||||
(thanks to Michael Schönitzer)
|
(thanks to Michael Schönitzer)
|
||||||
* Update generic process field display
|
* Update generic process field display
|
||||||
@ -48,20 +81,20 @@ What's new in version 3.1.0
|
|||||||
* Option and key ("*") to collapse / expand all branches under PID 1
|
* Option and key ("*") to collapse / expand all branches under PID 1
|
||||||
(and PID 2 if kernel threads are shown) (thanks to Krishna Chaitanya)
|
(and PID 2 if kernel threads are shown) (thanks to Krishna Chaitanya)
|
||||||
* Keep following a process when inverting the sort order, displaying
|
* Keep following a process when inverting the sort order, displaying
|
||||||
the help screen or hiding/unhiding userland threads
|
the help screen or hiding/unhiding userland threads.
|
||||||
If a thread is currently selected the selection is updated to point
|
If a thread is currently selected the selection is updated to point
|
||||||
to the thread's parent process. (thanks to Gonzalo, et.al.)
|
to the thread's parent process. (thanks to Gonzalo, et.al.)
|
||||||
* Reorder process scanning to be performed before updating the display
|
* Reorder process scanning to be performed before updating the display
|
||||||
of the meters in the header
|
of the meters in the header
|
||||||
* Always check the user for a process for any changes
|
* Always check the user for a process for any changes.
|
||||||
This affects multiple platforms that previously didn't correctly handle
|
This affects multiple platforms that previously didn't correctly handle
|
||||||
the user field for a process to change at runtime (e.g. due to seteuid
|
the user field for a process to change at runtime (e.g. due to seteuid
|
||||||
or similar syscalls).
|
or similar syscalls).
|
||||||
* Disable mouse option when support is unavailable
|
* Disable mouse option when support is unavailable
|
||||||
* Support curses libraries without ncurses mouse support
|
* Support curses libraries without ncurses mouse support
|
||||||
(thanks to Santhosh Raju)
|
(thanks to Santhosh Raju)
|
||||||
* Support offline and hot-swapping of CPUs on all platforms
|
* Support offline and hot-swapping of CPUs on all platforms
|
||||||
* Fix the CPU Meter for machines with more than 256 CPUs
|
* Fix the CPU Meter for machines with more than 256 CPUs
|
||||||
* Supplemented the "show updated/deleted executables" feature (red basename)
|
* Supplemented the "show updated/deleted executables" feature (red basename)
|
||||||
to indicate when linked libraries were updated (yellow basename)
|
to indicate when linked libraries were updated (yellow basename)
|
||||||
* Apply the stale binary highlighting for the EXE column in addition to
|
* Apply the stale binary highlighting for the EXE column in addition to
|
||||||
@ -94,55 +127,55 @@ What's new in version 3.1.0
|
|||||||
(thanks to Santhosh Raju and Nia Alarie)
|
(thanks to Santhosh Raju and Nia Alarie)
|
||||||
* Add NetworkIO, DiskIO, CPU frequency, and battery meter support on NetBSD
|
* Add NetworkIO, DiskIO, CPU frequency, and battery meter support on NetBSD
|
||||||
(thanks to Nia Alarie)
|
(thanks to Nia Alarie)
|
||||||
* Fix NetBSD display of in-use and cached memory (thanks to Nia Alarie)
|
* Fix NetBSD display of in-use and cached memory (thanks to Nia Alarie)
|
||||||
* Rework NetBSD CPU and memory accounting (thanks to Santhosh Raju)
|
* Rework NetBSD CPU and memory accounting (thanks to Santhosh Raju)
|
||||||
* Fix NetBSD accounting of user and kernel threads (thanks to Santhosh Raju)
|
* Fix NetBSD accounting of user and kernel threads (thanks to Santhosh Raju)
|
||||||
* Initial work to allow building with default libcurses on NetBSD
|
* Initial work to allow building with default libcurses on NetBSD
|
||||||
(thanks to Santhosh Raju)
|
(thanks to Santhosh Raju)
|
||||||
* FreeBSD updates - implement process majflt and processor column values
|
* FreeBSD updates - implement process majflt and processor column values
|
||||||
* Add FreeBSD support for CPU frequency and temperature
|
* Add FreeBSD support for CPU frequency and temperature
|
||||||
* Fixes and cleanups for ZFS Meters and metrics
|
* Fixes and cleanups for ZFS Meters and metrics
|
||||||
* Correctly color the ZFS ARC ratio (thanks to Ross Williams)
|
* Correctly color the ZFS ARC ratio (thanks to Ross Williams)
|
||||||
* Bugfixes related to CPU time display/calculations for darwin on M1 systems
|
* Bugfixes related to CPU time display/calculations for darwin on M1 systems
|
||||||
(thanks to Alexander Momchilov)
|
(thanks to Alexander Momchilov)
|
||||||
* Harmonize the handling of multiple batteries across different platforms
|
* Harmonize the handling of multiple batteries across different platforms.
|
||||||
The system is now considered to run on AC if at least one power supply
|
The system is now considered to run on AC if at least one power supply
|
||||||
marked as AC is found in the system.
|
marked as AC is found in the system.
|
||||||
Battery capacity is summed up over all batteries found.
|
Battery capacity is summed up over all batteries found.
|
||||||
This also changes the old behavior that batteries reported by the
|
This also changes the old behavior that batteries reported by the
|
||||||
system after the first AC adapter where sometimes ignored.
|
system after the first AC adapter where sometimes ignored.
|
||||||
* Correctly handle multiple batteries on Darwin
|
* Correctly handle multiple batteries on Darwin.
|
||||||
Resolves a possible memory leak on systems with multiple batteries
|
Resolves a possible memory leak on systems with multiple batteries.
|
||||||
* Handle Linux Shmem being part of Cached in the MemoryMeter
|
* Handle Linux Shmem being part of Cached in the MemoryMeter
|
||||||
* Add SwapCached to the Linux swap meter (thanks to David Zarzycki)
|
* Add SwapCached to the Linux swap meter (thanks to David Zarzycki)
|
||||||
* Convert process time to days if applicable (thanks to David Zarzycki)
|
* Convert process time to days if applicable (thanks to David Zarzycki)
|
||||||
* Always show the number of threads in the TaskMeter, even when threads
|
* Always show the number of threads in the TaskMeter, even when threads
|
||||||
are not shown in the process list
|
are not shown in the process list
|
||||||
* Fix Linux --drop-capabilities option handling
|
* Fix Linux --drop-capabilities option handling
|
||||||
* Correctly detect failure to initialize Linux boottime
|
* Correctly detect failure to initialize Linux boottime
|
||||||
* Overhaul the Linux memory fields to partition them like free(1) now does
|
* Overhaul the Linux memory fields to partition them like free(1) now does
|
||||||
* Improve the Linux process I/O column values
|
* Improve the Linux process I/O column values
|
||||||
* Rework the libsensors parsing on Linux
|
* Rework the libsensors parsing on Linux
|
||||||
* Update the MemoryMeter to display shared memory
|
* Update the MemoryMeter to display shared memory
|
||||||
* Update OpenBSD platform - implement additional columns, scan LWP,
|
* Update OpenBSD platform - implement additional columns, scan LWP,
|
||||||
proper markup for STATE, show CPU frequency
|
proper markup for STATE, show CPU frequency
|
||||||
* Fix the tree view on OpenBSD when hiding kernel threads
|
* Fix the tree view on OpenBSD when hiding kernel threads
|
||||||
* Remove old InfoScreen lines before re-scanning (thanks to Øystein Hiåsen)
|
* Remove old InfoScreen lines before re-scanning (thanks to Øystein Hiåsen)
|
||||||
* Document historic naming of Light-Weight Processes column aka threads
|
* Document historic naming of Light-Weight Processes column aka threads
|
||||||
* Improve user interaction when the last process entry is selected
|
* Improve user interaction when the last process entry is selected
|
||||||
* Draw the panel header on the TraceScreen (thanks to Youngjae Lee)
|
* Draw the panel header on the TraceScreen (thanks to Youngjae Lee)
|
||||||
* Add mouse wheel scroll and fix mouse selection on the InfoScreen
|
* Add mouse wheel scroll and fix mouse selection on the InfoScreen
|
||||||
(thanks to Youngjae Lee)
|
(thanks to Youngjae Lee)
|
||||||
* Add a HugepageMeter and subtract hugepages from normal memory
|
* Add a HugepageMeter and subtract hugepages from normal memory
|
||||||
* Display wide characters in LED meters and restore non-wide ncurses support
|
* Display wide characters in LED meters and restore non-wide ncurses support
|
||||||
* Add command line option to drop Linux capabilities
|
* Add command line option to drop Linux capabilities
|
||||||
* Support scheduler affinity on platforms beyond Linux
|
* Support scheduler affinity on platforms beyond Linux
|
||||||
* Report on any failure to write the configuration file
|
* Report on any failure to write the configuration file
|
||||||
* Cache stderr to be able to print assert messages
|
* Cache stderr to be able to print assert messages.
|
||||||
These messages are shown in case htop terminates unexpectedly.
|
These messages are shown in case htop terminates unexpectedly.
|
||||||
* Print current settings on crash
|
* Print current settings on crash
|
||||||
* Reset signal handlers on program exit
|
* Reset signal handlers on program exit
|
||||||
* Add configure script option to create a static htop binary
|
* Add configure script option to create a static htop binary
|
||||||
* Resolved longer-standing compilation issues on Solaris/Illumos
|
* Resolved longer-standing compilation issues on Solaris/Illumos
|
||||||
* Check for availability of set_escdelay in configure
|
* Check for availability of set_escdelay in configure
|
||||||
(thanks to Stefan Polluks)
|
(thanks to Stefan Polluks)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ClockMeter.c
|
htop - ClockMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ClockMeter.h
|
htop - ClockMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ColorsPanel.c
|
htop - ColorsPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ static HandlerResult ColorsPanel_eventHandler(Panel* super, int ch) {
|
|||||||
HandlerResult result = IGNORED;
|
HandlerResult result = IGNORED;
|
||||||
int mark;
|
int mark;
|
||||||
|
|
||||||
switch(ch) {
|
switch (ch) {
|
||||||
case 0x0a:
|
case 0x0a:
|
||||||
case 0x0d:
|
case 0x0d:
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ColorsPanel.h
|
htop - ColorsPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ColumnsPanel.c
|
htop - ColumnsPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -118,12 +118,6 @@ const PanelClass ColumnsPanel_class = {
|
|||||||
.eventHandler = ColumnsPanel_eventHandler
|
.eventHandler = ColumnsPanel_eventHandler
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
Panel* super;
|
|
||||||
unsigned int id;
|
|
||||||
unsigned int offset;
|
|
||||||
} DynamicIterator;
|
|
||||||
|
|
||||||
static void ColumnsPanel_add(Panel* super, unsigned int key, Hashtable* columns) {
|
static void ColumnsPanel_add(Panel* super, unsigned int key, Hashtable* columns) {
|
||||||
const char* name;
|
const char* name;
|
||||||
if (key < LAST_PROCESSFIELD) {
|
if (key < LAST_PROCESSFIELD) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ColumnsPanel.h
|
htop - ColumnsPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
100
CommandLine.c
100
CommandLine.c
@ -2,7 +2,7 @@
|
|||||||
htop - CommandLine.c
|
htop - CommandLine.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
(C) 2020-2021 htop dev team
|
(C) 2020-2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -11,6 +11,7 @@ in the source distribution for its full text.
|
|||||||
#include "CommandLine.h"
|
#include "CommandLine.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -47,7 +48,7 @@ static void printVersionFlag(const char* name) {
|
|||||||
static void printHelpFlag(const char* name) {
|
static void printHelpFlag(const char* name) {
|
||||||
printf("%s " VERSION "\n"
|
printf("%s " VERSION "\n"
|
||||||
COPYRIGHT "\n"
|
COPYRIGHT "\n"
|
||||||
"Released under the GNU GPLv2.\n\n"
|
"Released under the GNU GPLv2+.\n\n"
|
||||||
"-C --no-color Use a monochrome color scheme\n"
|
"-C --no-color Use a monochrome color scheme\n"
|
||||||
"-d --delay=DELAY Set the delay between updates, in tenths of seconds\n"
|
"-d --delay=DELAY Set the delay between updates, in tenths of seconds\n"
|
||||||
"-F --filter=FILTER Show only the commands matching the given filter\n"
|
"-F --filter=FILTER Show only the commands matching the given filter\n"
|
||||||
@ -85,9 +86,9 @@ typedef struct CommandLineSettings_ {
|
|||||||
bool readonly;
|
bool readonly;
|
||||||
} CommandLineSettings;
|
} CommandLineSettings;
|
||||||
|
|
||||||
static CommandLineSettings parseArguments(const char* program, int argc, char** argv) {
|
static CommandLineStatus parseArguments(const char* program, int argc, char** argv, CommandLineSettings* flags) {
|
||||||
|
|
||||||
CommandLineSettings flags = {
|
*flags = (CommandLineSettings) {
|
||||||
.pidMatchList = NULL,
|
.pidMatchList = NULL,
|
||||||
.commFilter = NULL,
|
.commFilter = NULL,
|
||||||
.userId = (uid_t)-1, // -1 is guaranteed to be an invalid uid_t (see setreuid(2))
|
.userId = (uid_t)-1, // -1 is guaranteed to be an invalid uid_t (see setreuid(2))
|
||||||
@ -130,10 +131,10 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
|
|||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
printHelpFlag(program);
|
printHelpFlag(program);
|
||||||
exit(0);
|
return STATUS_OK_EXIT;
|
||||||
case 'V':
|
case 'V':
|
||||||
printVersionFlag(program);
|
printVersionFlag(program);
|
||||||
exit(0);
|
return STATUS_OK_EXIT;
|
||||||
case 's':
|
case 's':
|
||||||
assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */
|
assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */
|
||||||
if (String_eq(optarg, "help")) {
|
if (String_eq(optarg, "help")) {
|
||||||
@ -142,29 +143,29 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
|
|||||||
const char* description = Process_fields[j].description;
|
const char* description = Process_fields[j].description;
|
||||||
if (name) printf("%19s %s\n", name, description);
|
if (name) printf("%19s %s\n", name, description);
|
||||||
}
|
}
|
||||||
exit(0);
|
return STATUS_OK_EXIT;
|
||||||
}
|
}
|
||||||
flags.sortKey = 0;
|
flags->sortKey = 0;
|
||||||
for (int j = 1; j < LAST_PROCESSFIELD; j++) {
|
for (int j = 1; j < LAST_PROCESSFIELD; j++) {
|
||||||
if (Process_fields[j].name == NULL)
|
if (Process_fields[j].name == NULL)
|
||||||
continue;
|
continue;
|
||||||
if (String_eq(optarg, Process_fields[j].name)) {
|
if (String_eq(optarg, Process_fields[j].name)) {
|
||||||
flags.sortKey = j;
|
flags->sortKey = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flags.sortKey == 0) {
|
if (flags->sortKey == 0) {
|
||||||
fprintf(stderr, "Error: invalid column \"%s\".\n", optarg);
|
fprintf(stderr, "Error: invalid column \"%s\".\n", optarg);
|
||||||
exit(1);
|
return STATUS_ERROR_EXIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if (sscanf(optarg, "%16d", &(flags.delay)) == 1) {
|
if (sscanf(optarg, "%16d", &(flags->delay)) == 1) {
|
||||||
if (flags.delay < 1) flags.delay = 1;
|
if (flags->delay < 1) flags->delay = 1;
|
||||||
if (flags.delay > 100) flags.delay = 100;
|
if (flags->delay > 100) flags->delay = 100;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Error: invalid delay value \"%s\".\n", optarg);
|
fprintf(stderr, "Error: invalid delay value \"%s\".\n", optarg);
|
||||||
exit(1);
|
return STATUS_ERROR_EXIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
@ -176,26 +177,30 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!username) {
|
if (!username) {
|
||||||
flags.userId = geteuid();
|
flags->userId = geteuid();
|
||||||
} else if (!Action_setUserOnly(username, &(flags.userId))) {
|
} else if (!Action_setUserOnly(username, &(flags->userId))) {
|
||||||
fprintf(stderr, "Error: invalid user \"%s\".\n", username);
|
for (const char *itr = username; *itr; ++itr)
|
||||||
exit(1);
|
if (!isdigit((unsigned char)*itr)) {
|
||||||
|
fprintf(stderr, "Error: invalid user \"%s\".\n", username);
|
||||||
|
return STATUS_ERROR_EXIT;
|
||||||
|
}
|
||||||
|
flags->userId = atol(username);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'C':
|
case 'C':
|
||||||
flags.useColors = false;
|
flags->useColors = false;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
#ifdef HAVE_GETMOUSE
|
#ifdef HAVE_GETMOUSE
|
||||||
flags.enableMouse = false;
|
flags->enableMouse = false;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
flags.allowUnicode = false;
|
flags->allowUnicode = false;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
flags.treeView = true;
|
flags->treeView = true;
|
||||||
break;
|
break;
|
||||||
case 'p': {
|
case 'p': {
|
||||||
assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */
|
assert(optarg); /* please clang analyzer, cause optarg can be NULL in the 'u' case */
|
||||||
@ -203,14 +208,14 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
|
|||||||
char* saveptr;
|
char* saveptr;
|
||||||
const char* pid = strtok_r(argCopy, ",", &saveptr);
|
const char* pid = strtok_r(argCopy, ",", &saveptr);
|
||||||
|
|
||||||
if (!flags.pidMatchList) {
|
if (!flags->pidMatchList) {
|
||||||
flags.pidMatchList = Hashtable_new(8, false);
|
flags->pidMatchList = Hashtable_new(8, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(pid) {
|
while(pid) {
|
||||||
unsigned int num_pid = atoi(pid);
|
unsigned int num_pid = atoi(pid);
|
||||||
// deepcode ignore CastIntegerToAddress: we just want a non-NUll pointer here
|
// deepcode ignore CastIntegerToAddress: we just want a non-NULL pointer here
|
||||||
Hashtable_put(flags.pidMatchList, num_pid, (void *) 1);
|
Hashtable_put(flags->pidMatchList, num_pid, (void *) 1);
|
||||||
pid = strtok_r(NULL, ",", &saveptr);
|
pid = strtok_r(NULL, ",", &saveptr);
|
||||||
}
|
}
|
||||||
free(argCopy);
|
free(argCopy);
|
||||||
@ -219,7 +224,7 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
|
|||||||
}
|
}
|
||||||
case 'F': {
|
case 'F': {
|
||||||
assert(optarg);
|
assert(optarg);
|
||||||
free_and_xStrdup(&flags.commFilter, optarg);
|
free_and_xStrdup(&flags->commFilter, optarg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'H': {
|
case 'H': {
|
||||||
@ -229,28 +234,30 @@ static CommandLineSettings parseArguments(const char* program, int argc, char**
|
|||||||
delay = argv[optind++];
|
delay = argv[optind++];
|
||||||
}
|
}
|
||||||
if (delay) {
|
if (delay) {
|
||||||
if (sscanf(delay, "%16d", &(flags.highlightDelaySecs)) == 1) {
|
if (sscanf(delay, "%16d", &(flags->highlightDelaySecs)) == 1) {
|
||||||
if (flags.highlightDelaySecs < 1)
|
if (flags->highlightDelaySecs < 1)
|
||||||
flags.highlightDelaySecs = 1;
|
flags->highlightDelaySecs = 1;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay);
|
fprintf(stderr, "Error: invalid highlight delay value \"%s\".\n", delay);
|
||||||
exit(1);
|
return STATUS_ERROR_EXIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flags.highlightChanges = true;
|
flags->highlightChanges = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 128:
|
case 128:
|
||||||
flags.readonly = true;
|
flags->readonly = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default: {
|
||||||
if (Platform_getLongOption(opt, argc, argv) == false)
|
CommandLineStatus status;
|
||||||
exit(1);
|
if ((status = Platform_getLongOption(opt, argc, argv)) != STATUS_OK)
|
||||||
break;
|
return status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flags;
|
return STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CommandLine_delay(ProcessList* pl, unsigned long millisec) {
|
static void CommandLine_delay(ProcessList* pl, unsigned long millisec) {
|
||||||
@ -283,12 +290,17 @@ int CommandLine_run(const char* name, int argc, char** argv) {
|
|||||||
else
|
else
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
|
|
||||||
CommandLineSettings flags = parseArguments(name, argc, argv);
|
CommandLineStatus status = STATUS_OK;
|
||||||
|
CommandLineSettings flags = { 0 };
|
||||||
|
|
||||||
|
if ((status = parseArguments(name, argc, argv, &flags)) != STATUS_OK)
|
||||||
|
return status != STATUS_OK_EXIT ? 1 : 0;
|
||||||
|
|
||||||
if (flags.readonly)
|
if (flags.readonly)
|
||||||
Settings_enableReadonly();
|
Settings_enableReadonly();
|
||||||
|
|
||||||
Platform_init();
|
if (!Platform_init())
|
||||||
|
return 1;
|
||||||
|
|
||||||
Process_setupColumnWidths();
|
Process_setupColumnWidths();
|
||||||
|
|
||||||
@ -393,10 +405,8 @@ int CommandLine_run(const char* name, int argc, char** argv) {
|
|||||||
|
|
||||||
/* Delete these last, since they can get accessed in the crash handler */
|
/* Delete these last, since they can get accessed in the crash handler */
|
||||||
Settings_delete(settings);
|
Settings_delete(settings);
|
||||||
if (dc)
|
DynamicColumns_delete(dc);
|
||||||
Hashtable_delete(dc);
|
DynamicMeters_delete(dm);
|
||||||
if (dm)
|
|
||||||
Hashtable_delete(dm);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,15 @@
|
|||||||
htop - CommandLine.h
|
htop - CommandLine.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
(C) 2020-2021 htop dev team
|
(C) 2020-2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
STATUS_OK,
|
||||||
|
STATUS_ERROR_EXIT,
|
||||||
|
STATUS_OK_EXIT
|
||||||
|
} CommandLineStatus;
|
||||||
|
|
||||||
int CommandLine_run(const char* name, int argc, char** argv);
|
int CommandLine_run(const char* name, int argc, char** argv);
|
||||||
|
|
||||||
|
4
Compat.c
4
Compat.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Compat.c
|
htop - Compat.c
|
||||||
(C) 2020 htop dev team
|
(C) 2020 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ int Compat_faccessat(int dirfd,
|
|||||||
|
|
||||||
// Fallback to stat(2)/lstat(2) depending on flags
|
// Fallback to stat(2)/lstat(2) depending on flags
|
||||||
struct stat statinfo;
|
struct stat statinfo;
|
||||||
if(flags) {
|
if (flags) {
|
||||||
ret = lstat(pathname, &statinfo);
|
ret = lstat(pathname, &statinfo);
|
||||||
} else {
|
} else {
|
||||||
ret = stat(pathname, &statinfo);
|
ret = stat(pathname, &statinfo);
|
||||||
|
2
Compat.h
2
Compat.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Compat.h
|
htop - Compat.h
|
||||||
(C) 2020 htop dev team
|
(C) 2020 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DateMeter.c
|
htop - DateMeter.c
|
||||||
(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
|
(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DateMeter.h
|
htop - DateMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DateTimeMeter.c
|
htop - DateTimeMeter.c
|
||||||
(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
|
(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DateTimeMeter.h
|
htop - DateTimeMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DiskIOMeter.c
|
htop - DiskIOMeter.c
|
||||||
(C) 2020 htop dev team
|
(C) 2020 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -81,6 +81,12 @@ static void DiskIOMeter_updateValues(Meter* this) {
|
|||||||
cached_msTimeSpend_total = data.totalMsTimeSpend;
|
cached_msTimeSpend_total = data.totalMsTimeSpend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (passedTimeInMs > 30000) {
|
||||||
|
// Triggers for the first initialization and
|
||||||
|
// when there was a long time we did not collect updates
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
|
||||||
this->values[0] = cached_utilisation_diff;
|
this->values[0] = cached_utilisation_diff;
|
||||||
this->total = MAXIMUM(this->values[0], 100.0); /* fix total after (initial) spike */
|
this->total = MAXIMUM(this->values[0], 100.0); /* fix total after (initial) spike */
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DiskIOMeter.h
|
htop - DiskIOMeter.h
|
||||||
(C) 2020 htop dev team
|
(C) 2020 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DisplayOptionsPanel.c
|
htop - DisplayOptionsPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
|
|||||||
Panel_add(super, (Object*) CheckItem_newByRef("Show custom thread names", &(settings->showThreadNames)));
|
Panel_add(super, (Object*) CheckItem_newByRef("Show custom thread names", &(settings->showThreadNames)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef("Show program path", &(settings->showProgramPath)));
|
Panel_add(super, (Object*) CheckItem_newByRef("Show program path", &(settings->showProgramPath)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef("Highlight program \"basename\"", &(settings->highlightBaseName)));
|
Panel_add(super, (Object*) CheckItem_newByRef("Highlight program \"basename\"", &(settings->highlightBaseName)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef("Highlight out-dated/removed programs", &(settings->highlightDeletedExe)));
|
Panel_add(super, (Object*) CheckItem_newByRef("Highlight out-dated/removed programs (red) / libraries (yellow)", &(settings->highlightDeletedExe)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef("Merge exe, comm and cmdline in Command", &(settings->showMergedCommand)));
|
Panel_add(super, (Object*) CheckItem_newByRef("Merge exe, comm and cmdline in Command", &(settings->showMergedCommand)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef("- Try to find comm in cmdline (when Command is merged)", &(settings->findCommInCmdline)));
|
Panel_add(super, (Object*) CheckItem_newByRef("- Try to find comm in cmdline (when Command is merged)", &(settings->findCommInCmdline)));
|
||||||
Panel_add(super, (Object*) CheckItem_newByRef("- Try to strip exe from cmdline (when Command is merged)", &(settings->stripExeFromCmdline)));
|
Panel_add(super, (Object*) CheckItem_newByRef("- Try to strip exe from cmdline (when Command is merged)", &(settings->stripExeFromCmdline)));
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - DisplayOptionsPanel.h
|
htop - DisplayOptionsPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ htop - DynamicColumn.c
|
|||||||
(C) 2021 Sohaib Mohammed
|
(C) 2021 Sohaib Mohammed
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
(C) 2021 Red Hat, Inc. All Rights Reserved.
|
(C) 2021 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -22,6 +22,13 @@ Hashtable* DynamicColumns_new(void) {
|
|||||||
return Platform_dynamicColumns();
|
return Platform_dynamicColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicColumns_delete(Hashtable* dynamics) {
|
||||||
|
if (dynamics) {
|
||||||
|
Platform_dynamicColumnsDone(dynamics);
|
||||||
|
Hashtable_delete(dynamics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char* DynamicColumn_init(unsigned int key) {
|
const char* DynamicColumn_init(unsigned int key) {
|
||||||
return Platform_dynamicColumnInit(key);
|
return Platform_dynamicColumnInit(key);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ typedef struct DynamicColumn_ {
|
|||||||
|
|
||||||
Hashtable* DynamicColumns_new(void);
|
Hashtable* DynamicColumns_new(void);
|
||||||
|
|
||||||
|
void DynamicColumns_delete(Hashtable* dynamics);
|
||||||
|
|
||||||
const char* DynamicColumn_init(unsigned int key);
|
const char* DynamicColumn_init(unsigned int key);
|
||||||
|
|
||||||
const DynamicColumn* DynamicColumn_lookup(Hashtable* dynamics, unsigned int key);
|
const DynamicColumn* DynamicColumn_lookup(Hashtable* dynamics, unsigned int key);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
htop - DynamicMeter.c
|
htop - DynamicMeter.c
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
(C) 2021 Red Hat, Inc. All Rights Reserved.
|
(C) 2021 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -38,6 +38,13 @@ Hashtable* DynamicMeters_new(void) {
|
|||||||
return Platform_dynamicMeters();
|
return Platform_dynamicMeters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicMeters_delete(Hashtable* dynamics) {
|
||||||
|
if (dynamics) {
|
||||||
|
Platform_dynamicMetersDone(dynamics);
|
||||||
|
Hashtable_delete(dynamics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
const char* name;
|
const char* name;
|
||||||
|
@ -17,6 +17,8 @@ typedef struct DynamicMeter_ {
|
|||||||
|
|
||||||
Hashtable* DynamicMeters_new(void);
|
Hashtable* DynamicMeters_new(void);
|
||||||
|
|
||||||
|
void DynamicMeters_delete(Hashtable* dynamics);
|
||||||
|
|
||||||
const char* DynamicMeter_lookup(Hashtable* dynamics, unsigned int key);
|
const char* DynamicMeter_lookup(Hashtable* dynamics, unsigned int key);
|
||||||
|
|
||||||
bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* key);
|
bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* key);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - FunctionBar.c
|
htop - FunctionBar.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - FunctionBar.h
|
htop - FunctionBar.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Hashtable.c
|
htop - Hashtable.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Hashtable.h
|
htop - Hashtable.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
24
Header.c
24
Header.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Header.c
|
htop - Header.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -86,8 +86,9 @@ static void Header_addMeterByName(Header* this, const char* name, MeterModeId mo
|
|||||||
if (paren) {
|
if (paren) {
|
||||||
int ok = sscanf(paren, "(%10u)", ¶m); // CPUMeter
|
int ok = sscanf(paren, "(%10u)", ¶m); // CPUMeter
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
char* end, dynamic[32] = {0};
|
char dynamic[32] = {0};
|
||||||
if (sscanf(paren, "(%30s)", dynamic)) { // DynamicMeter
|
if (sscanf(paren, "(%30s)", dynamic)) { // DynamicMeter
|
||||||
|
char* end;
|
||||||
if ((end = strrchr(dynamic, ')')) == NULL)
|
if ((end = strrchr(dynamic, ')')) == NULL)
|
||||||
return; // htoprc parse failure
|
return; // htoprc parse failure
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
@ -144,7 +145,7 @@ void Header_writeBackToSettings(const Header* this) {
|
|||||||
const Vector* vec = this->columns[col];
|
const Vector* vec = this->columns[col];
|
||||||
int len = Vector_size(vec);
|
int len = Vector_size(vec);
|
||||||
|
|
||||||
colSettings->names = len ? xCalloc(len, sizeof(char*)) : NULL;
|
colSettings->names = len ? xCalloc(len + 1, sizeof(char*)) : NULL;
|
||||||
colSettings->modes = len ? xCalloc(len, sizeof(int)) : NULL;
|
colSettings->modes = len ? xCalloc(len, sizeof(int)) : NULL;
|
||||||
colSettings->len = len;
|
colSettings->len = len;
|
||||||
|
|
||||||
@ -195,25 +196,28 @@ void Header_draw(const Header* this) {
|
|||||||
}
|
}
|
||||||
const int width = COLS - pad;
|
const int width = COLS - pad;
|
||||||
int x = pad;
|
int x = pad;
|
||||||
float roundingLoss = 0.0f;
|
float roundingLoss = 0.0F;
|
||||||
|
|
||||||
Header_forEachColumn(this, col) {
|
Header_forEachColumn(this, col) {
|
||||||
Vector* meters = this->columns[col];
|
Vector* meters = this->columns[col];
|
||||||
float colWidth = (float)width * HeaderLayout_layouts[this->headerLayout].widths[col] / 100.0f;
|
float colWidth = (float)width * HeaderLayout_layouts[this->headerLayout].widths[col] / 100.0F;
|
||||||
|
|
||||||
roundingLoss += colWidth - floorf(colWidth);
|
roundingLoss += colWidth - floorf(colWidth);
|
||||||
if (roundingLoss >= 1.0f) {
|
if (roundingLoss >= 1.0F) {
|
||||||
colWidth += 1.0f;
|
colWidth += 1.0F;
|
||||||
roundingLoss -= 1.0f;
|
roundingLoss -= 1.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) {
|
for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) {
|
||||||
Meter* meter = (Meter*) Vector_get(meters, i);
|
Meter* meter = (Meter*) Vector_get(meters, i);
|
||||||
|
|
||||||
float actualWidth = colWidth;
|
float actualWidth = colWidth;
|
||||||
if (meter->mode == TEXT_METERMODE) {
|
|
||||||
|
/* Let meters in text mode expand to the right on empty neighbors;
|
||||||
|
except for multi column meters. */
|
||||||
|
if (meter->mode == TEXT_METERMODE && !Meter_isMultiColumn(meter)) {
|
||||||
for (int j = 1; j < meter->columnWidthCount; j++) {
|
for (int j = 1; j < meter->columnWidthCount; j++) {
|
||||||
actualWidth += (float)width * HeaderLayout_layouts[this->headerLayout].widths[col + j] / 100.0f;
|
actualWidth += (float)width * HeaderLayout_layouts[this->headerLayout].widths[col + j] / 100.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
Header.h
4
Header.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Header.h
|
htop - Header.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ typedef struct Header_ {
|
|||||||
int height;
|
int height;
|
||||||
} Header;
|
} Header;
|
||||||
|
|
||||||
#define Header_forEachColumn(this_, i_) for (size_t (i_)=0; (i_) < HeaderLayout_getColumns((this_)->headerLayout); ++(i_))
|
#define Header_forEachColumn(this_, i_) for (size_t (i_)=0, H_fEC_numColumns_ = HeaderLayout_getColumns((this_)->headerLayout); (i_) < H_fEC_numColumns_; ++(i_))
|
||||||
|
|
||||||
Header* Header_new(ProcessList* pl, Settings* settings, HeaderLayout hLayout);
|
Header* Header_new(ProcessList* pl, Settings* settings, HeaderLayout hLayout);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - HeaderLayout.h
|
htop - HeaderLayout.h
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - HeaderOptionsPanel.c
|
htop - HeaderOptionsPanel.c
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ static HandlerResult HeaderOptionsPanel_eventHandler(Panel* super, int ch) {
|
|||||||
HandlerResult result = IGNORED;
|
HandlerResult result = IGNORED;
|
||||||
int mark;
|
int mark;
|
||||||
|
|
||||||
switch(ch) {
|
switch (ch) {
|
||||||
case 0x0a:
|
case 0x0a:
|
||||||
case 0x0d:
|
case 0x0d:
|
||||||
case KEY_ENTER:
|
case KEY_ENTER:
|
||||||
@ -82,6 +82,6 @@ HeaderOptionsPanel* HeaderOptionsPanel_new(Settings* settings, ScreenManager* sc
|
|||||||
for (int i = 0; i < LAST_HEADER_LAYOUT; i++) {
|
for (int i = 0; i < LAST_HEADER_LAYOUT; i++) {
|
||||||
Panel_add(super, (Object*) CheckItem_newByVal(HeaderLayout_layouts[i].description, false));
|
Panel_add(super, (Object*) CheckItem_newByVal(HeaderLayout_layouts[i].description, false));
|
||||||
}
|
}
|
||||||
CheckItem_set((CheckItem*)Panel_get(super, settings->hLayout), true);
|
CheckItem_set((CheckItem*)Panel_get(super, scr->header->headerLayout), true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ColorsPanel.h
|
htop - ColorsPanel.h
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - HostnameMeter.c
|
htop - HostnameMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - HostnameMeter.h
|
htop - HostnameMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
4
IncSet.c
4
IncSet.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - IncSet.c
|
htop - IncSet.c
|
||||||
(C) 2005-2012 Hisham H. Muhammad
|
(C) 2005-2012 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
|
|||||||
doSearch = false;
|
doSearch = false;
|
||||||
} else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) {
|
} else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) {
|
||||||
if (mode->index < INCMODE_MAX) {
|
if (mode->index < INCMODE_MAX) {
|
||||||
mode->buffer[mode->index] = ch;
|
mode->buffer[mode->index] = (char) ch;
|
||||||
mode->index++;
|
mode->index++;
|
||||||
mode->buffer[mode->index] = 0;
|
mode->buffer[mode->index] = 0;
|
||||||
if (mode->isFilter) {
|
if (mode->isFilter) {
|
||||||
|
2
IncSet.h
2
IncSet.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - IncSet.h
|
htop - IncSet.h
|
||||||
(C) 2005-2012 Hisham H. Muhammad
|
(C) 2005-2012 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void InfoScreen_run(InfoScreen* this) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(ch) {
|
switch (ch) {
|
||||||
case ERR:
|
case ERR:
|
||||||
continue;
|
continue;
|
||||||
case KEY_F(3):
|
case KEY_F(3):
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ListItem.c
|
htop - ListItem.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ListItem.h
|
htop - ListItem.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - LoadAverageMeter.c
|
htop - LoadAverageMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - LoadAverageMeter.h
|
htop - LoadAverageMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
10
MainPanel.c
10
MainPanel.c
@ -2,7 +2,7 @@
|
|||||||
htop - ColumnsPanel.c
|
htop - ColumnsPanel.c
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -62,7 +62,13 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
|
|||||||
return IGNORED;
|
return IGNORED;
|
||||||
|
|
||||||
/* reset on every normal key */
|
/* reset on every normal key */
|
||||||
if (ch != ERR)
|
bool needReset = ch != ERR;
|
||||||
|
#ifdef HAVE_GETMOUSE
|
||||||
|
/* except mouse events while mouse support is disabled */
|
||||||
|
if (!(ch != KEY_MOUSE || this->state->settings->enableMouse))
|
||||||
|
needReset = false;
|
||||||
|
#endif
|
||||||
|
if (needReset)
|
||||||
this->state->hideProcessSelection = false;
|
this->state->hideProcessSelection = false;
|
||||||
|
|
||||||
if (EVENT_IS_HEADER_CLICK(ch)) {
|
if (EVENT_IS_HEADER_CLICK(ch)) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
htop - ColumnsPanel.h
|
htop - ColumnsPanel.h
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
26
Makefile.am
26
Makefile.am
@ -1,3 +1,11 @@
|
|||||||
|
if !HTOP_PCP
|
||||||
|
bin_PROGRAMS = htop
|
||||||
|
myhtopplatprogram = htop.c
|
||||||
|
else
|
||||||
|
bin_PROGRAMS = pcp-htop
|
||||||
|
myhtopplatprogram = pcp-htop.c
|
||||||
|
endif
|
||||||
|
|
||||||
dist_man_MANS = htop.1
|
dist_man_MANS = htop.1
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
$(dist_man_MANS) \
|
$(dist_man_MANS) \
|
||||||
@ -145,6 +153,7 @@ linux_platform_headers = \
|
|||||||
generic/gettime.h \
|
generic/gettime.h \
|
||||||
generic/hostname.h \
|
generic/hostname.h \
|
||||||
generic/uname.h \
|
generic/uname.h \
|
||||||
|
linux/CGroupUtils.h \
|
||||||
linux/HugePageMeter.h \
|
linux/HugePageMeter.h \
|
||||||
linux/IOPriority.h \
|
linux/IOPriority.h \
|
||||||
linux/IOPriorityPanel.h \
|
linux/IOPriorityPanel.h \
|
||||||
@ -166,6 +175,7 @@ linux_platform_sources = \
|
|||||||
generic/gettime.c \
|
generic/gettime.c \
|
||||||
generic/hostname.c \
|
generic/hostname.c \
|
||||||
generic/uname.c \
|
generic/uname.c \
|
||||||
|
linux/CGroupUtils.c \
|
||||||
linux/HugePageMeter.c \
|
linux/HugePageMeter.c \
|
||||||
linux/IOPriorityPanel.c \
|
linux/IOPriorityPanel.c \
|
||||||
linux/LibSensors.c \
|
linux/LibSensors.c \
|
||||||
@ -181,7 +191,6 @@ linux_platform_sources = \
|
|||||||
|
|
||||||
if HTOP_LINUX
|
if HTOP_LINUX
|
||||||
AM_LDFLAGS += -rdynamic
|
AM_LDFLAGS += -rdynamic
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(linux_platform_headers)
|
myhtopplatheaders = $(linux_platform_headers)
|
||||||
myhtopplatsources = $(linux_platform_sources)
|
myhtopplatsources = $(linux_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -214,7 +223,6 @@ freebsd_platform_sources = \
|
|||||||
zfs/ZfsCompressedArcMeter.c
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
if HTOP_FREEBSD
|
if HTOP_FREEBSD
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(freebsd_platform_headers)
|
myhtopplatheaders = $(freebsd_platform_headers)
|
||||||
myhtopplatsources = $(freebsd_platform_sources)
|
myhtopplatsources = $(freebsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -240,7 +248,6 @@ dragonflybsd_platform_sources = \
|
|||||||
generic/uname.c
|
generic/uname.c
|
||||||
|
|
||||||
if HTOP_DRAGONFLYBSD
|
if HTOP_DRAGONFLYBSD
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(dragonflybsd_platform_headers)
|
myhtopplatheaders = $(dragonflybsd_platform_headers)
|
||||||
myhtopplatsources = $(dragonflybsd_platform_sources)
|
myhtopplatsources = $(dragonflybsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -266,7 +273,6 @@ netbsd_platform_sources = \
|
|||||||
netbsd/NetBSDProcessList.c
|
netbsd/NetBSDProcessList.c
|
||||||
|
|
||||||
if HTOP_NETBSD
|
if HTOP_NETBSD
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(netbsd_platform_headers)
|
myhtopplatheaders = $(netbsd_platform_headers)
|
||||||
myhtopplatsources = $(netbsd_platform_sources)
|
myhtopplatsources = $(netbsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -292,7 +298,6 @@ openbsd_platform_sources = \
|
|||||||
openbsd/Platform.c
|
openbsd/Platform.c
|
||||||
|
|
||||||
if HTOP_OPENBSD
|
if HTOP_OPENBSD
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(openbsd_platform_headers)
|
myhtopplatheaders = $(openbsd_platform_headers)
|
||||||
myhtopplatsources = $(openbsd_platform_sources)
|
myhtopplatsources = $(openbsd_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -304,6 +309,7 @@ darwin_platform_headers = \
|
|||||||
darwin/DarwinProcess.h \
|
darwin/DarwinProcess.h \
|
||||||
darwin/DarwinProcessList.h \
|
darwin/DarwinProcessList.h \
|
||||||
darwin/Platform.h \
|
darwin/Platform.h \
|
||||||
|
darwin/PlatformHelpers.h \
|
||||||
darwin/ProcessField.h \
|
darwin/ProcessField.h \
|
||||||
generic/gettime.h \
|
generic/gettime.h \
|
||||||
generic/hostname.h \
|
generic/hostname.h \
|
||||||
@ -315,6 +321,7 @@ darwin_platform_headers = \
|
|||||||
|
|
||||||
darwin_platform_sources = \
|
darwin_platform_sources = \
|
||||||
darwin/Platform.c \
|
darwin/Platform.c \
|
||||||
|
darwin/PlatformHelpers.c \
|
||||||
darwin/DarwinProcess.c \
|
darwin/DarwinProcess.c \
|
||||||
darwin/DarwinProcessList.c \
|
darwin/DarwinProcessList.c \
|
||||||
generic/gettime.c \
|
generic/gettime.c \
|
||||||
@ -326,7 +333,6 @@ darwin_platform_sources = \
|
|||||||
|
|
||||||
if HTOP_DARWIN
|
if HTOP_DARWIN
|
||||||
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
|
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(darwin_platform_headers)
|
myhtopplatheaders = $(darwin_platform_headers)
|
||||||
myhtopplatsources = $(darwin_platform_sources)
|
myhtopplatsources = $(darwin_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -357,7 +363,6 @@ solaris_platform_sources = \
|
|||||||
zfs/ZfsCompressedArcMeter.c
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
if HTOP_SOLARIS
|
if HTOP_SOLARIS
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatheaders = $(solaris_platform_headers)
|
myhtopplatheaders = $(solaris_platform_headers)
|
||||||
myhtopplatsources = $(solaris_platform_sources)
|
myhtopplatsources = $(solaris_platform_sources)
|
||||||
endif
|
endif
|
||||||
@ -393,10 +398,9 @@ pcp_platform_sources = \
|
|||||||
zfs/ZfsCompressedArcMeter.c
|
zfs/ZfsCompressedArcMeter.c
|
||||||
|
|
||||||
if HTOP_PCP
|
if HTOP_PCP
|
||||||
myhtopplatprogram = pcp-htop
|
|
||||||
myhtopplatheaders = $(pcp_platform_headers)
|
myhtopplatheaders = $(pcp_platform_headers)
|
||||||
myhtopplatsources = $(pcp_platform_sources)
|
myhtopplatsources = $(pcp_platform_sources)
|
||||||
pcp_htop_SOURCES = $(myhtopplatprogram).c $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
|
pcp_htop_SOURCES = $(myhtopplatprogram) $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Unsupported
|
# Unsupported
|
||||||
@ -416,15 +420,13 @@ unsupported_platform_sources = \
|
|||||||
unsupported/UnsupportedProcessList.c
|
unsupported/UnsupportedProcessList.c
|
||||||
|
|
||||||
if HTOP_UNSUPPORTED
|
if HTOP_UNSUPPORTED
|
||||||
myhtopplatprogram = htop
|
|
||||||
myhtopplatsources = $(unsupported_platform_sources)
|
myhtopplatsources = $(unsupported_platform_sources)
|
||||||
myhtopplatheaders = $(unsupported_platform_headers)
|
myhtopplatheaders = $(unsupported_platform_headers)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ----
|
# ----
|
||||||
|
|
||||||
bin_PROGRAMS = $(myhtopplatprogram)
|
htop_SOURCES = $(myhtopplatprogram) $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
|
||||||
htop_SOURCES = $(myhtopplatprogram).c $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
|
|
||||||
nodist_htop_SOURCES = config.h
|
nodist_htop_SOURCES = config.h
|
||||||
|
|
||||||
target:
|
target:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - MemoryMeter.c
|
htop - MemoryMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ static void MemoryMeter_updateValues(Meter* this) {
|
|||||||
/* Do not print available memory in bar mode */
|
/* Do not print available memory in bar mode */
|
||||||
this->curItems = 4;
|
this->curItems = 4;
|
||||||
|
|
||||||
written = Meter_humanUnit(buffer, isnan(this->values[4]) ? this->values[0] : this->total - this->values[4], size);
|
written = Meter_humanUnit(buffer, this->values[0], size);
|
||||||
METER_BUFFER_CHECK(buffer, size, written);
|
METER_BUFFER_CHECK(buffer, size, written);
|
||||||
|
|
||||||
METER_BUFFER_APPEND_CHR(buffer, size, '/');
|
METER_BUFFER_APPEND_CHR(buffer, size, '/');
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - MemoryMeter.h
|
htop - MemoryMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - MemorySwapMeter.c
|
htop - MemorySwapMeter.c
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -33,10 +33,14 @@ static void MemorySwapMeter_updateValues(Meter* this) {
|
|||||||
static void MemorySwapMeter_draw(Meter* this, int x, int y, int w) {
|
static void MemorySwapMeter_draw(Meter* this, int x, int y, int w) {
|
||||||
MemorySwapMeterData* data = this->meterData;
|
MemorySwapMeterData* data = this->meterData;
|
||||||
|
|
||||||
|
/* Use the same width for each sub meter to align with CPU meter */
|
||||||
|
const int colwidth = w / 2;
|
||||||
|
const int diff = w - colwidth * 2;
|
||||||
|
|
||||||
assert(data->memoryMeter->draw);
|
assert(data->memoryMeter->draw);
|
||||||
data->memoryMeter->draw(data->memoryMeter, x, y, w / 2);
|
data->memoryMeter->draw(data->memoryMeter, x, y, colwidth);
|
||||||
assert(data->swapMeter->draw);
|
assert(data->swapMeter->draw);
|
||||||
data->swapMeter->draw(data->swapMeter, x + w / 2, y, w - w / 2);
|
data->swapMeter->draw(data->swapMeter, x + colwidth + diff, y, colwidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MemorySwapMeter_init(Meter* this) {
|
static void MemorySwapMeter_init(Meter* this) {
|
||||||
@ -91,6 +95,7 @@ const MeterClass MemorySwapMeter_class = {
|
|||||||
},
|
},
|
||||||
.updateValues = MemorySwapMeter_updateValues,
|
.updateValues = MemorySwapMeter_updateValues,
|
||||||
.defaultMode = CUSTOM_METERMODE,
|
.defaultMode = CUSTOM_METERMODE,
|
||||||
|
.isMultiColumn = true,
|
||||||
.name = "MemorySwap",
|
.name = "MemorySwap",
|
||||||
.uiName = "Memory & Swap",
|
.uiName = "Memory & Swap",
|
||||||
.description = "Combined memory and swap usage",
|
.description = "Combined memory and swap usage",
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - MemorySwapMeter.h
|
htop - MemorySwapMeter.h
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
2
Meter.c
2
Meter.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Meter.c
|
htop - Meter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
4
Meter.h
4
Meter.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Meter.h
|
htop - Meter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ typedef struct MeterClass_ {
|
|||||||
const char* const caption; /* prefix in the actual header */
|
const char* const caption; /* prefix in the actual header */
|
||||||
const char* const description; /* optional meter description in header setup menu */
|
const char* const description; /* optional meter description in header setup menu */
|
||||||
const uint8_t maxItems;
|
const uint8_t maxItems;
|
||||||
|
const bool isMultiColumn; /* whether the meter draws multiple sub-columns (defaults to false) */
|
||||||
} MeterClass;
|
} MeterClass;
|
||||||
|
|
||||||
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
|
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
|
||||||
@ -92,6 +93,7 @@ typedef struct MeterClass_ {
|
|||||||
#define Meter_attributes(this_) As_Meter(this_)->attributes
|
#define Meter_attributes(this_) As_Meter(this_)->attributes
|
||||||
#define Meter_name(this_) As_Meter(this_)->name
|
#define Meter_name(this_) As_Meter(this_)->name
|
||||||
#define Meter_uiName(this_) As_Meter(this_)->uiName
|
#define Meter_uiName(this_) As_Meter(this_)->uiName
|
||||||
|
#define Meter_isMultiColumn(this_) As_Meter(this_)->isMultiColumn
|
||||||
|
|
||||||
typedef struct GraphData_ {
|
typedef struct GraphData_ {
|
||||||
struct timeval time;
|
struct timeval time;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - MetersPanel.c
|
htop - MetersPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - MetersPanel.h
|
htop - MetersPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -85,6 +85,12 @@ static void NetworkIOMeter_updateValues(Meter* this) {
|
|||||||
cached_txp_total = data.packetsTransmitted;
|
cached_txp_total = data.packetsTransmitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (passedTimeInMs > 30000) {
|
||||||
|
// Triggers for the first initialization and
|
||||||
|
// when there was a long time we did not collect updates
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
|
||||||
this->values[0] = cached_rxb_diff;
|
this->values[0] = cached_rxb_diff;
|
||||||
this->values[1] = cached_txb_diff;
|
this->values[1] = cached_txb_diff;
|
||||||
if (cached_rxb_diff + cached_txb_diff > this->total) {
|
if (cached_rxb_diff + cached_txb_diff > this->total) {
|
||||||
|
2
Object.c
2
Object.c
@ -2,7 +2,7 @@
|
|||||||
htop - Object.c
|
htop - Object.c
|
||||||
(C) 2004-2012 Hisham H. Muhammad
|
(C) 2004-2012 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
2
Object.h
2
Object.h
@ -4,7 +4,7 @@
|
|||||||
htop - Object.h
|
htop - Object.h
|
||||||
(C) 2004-2012 Hisham H. Muhammad
|
(C) 2004-2012 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - OpenFilesScreen.c
|
htop - OpenFilesScreen.c
|
||||||
(C) 2005-2006 Hisham H. Muhammad
|
(C) 2005-2006 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -10,12 +10,14 @@ in the source distribution for its full text.
|
|||||||
#include "OpenFilesScreen.h"
|
#include "OpenFilesScreen.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "Macros.h"
|
#include "Macros.h"
|
||||||
#include "Panel.h"
|
#include "Panel.h"
|
||||||
@ -25,7 +27,7 @@ in the source distribution for its full text.
|
|||||||
|
|
||||||
|
|
||||||
typedef struct OpenFiles_Data_ {
|
typedef struct OpenFiles_Data_ {
|
||||||
char* data[7];
|
char* data[8];
|
||||||
} OpenFiles_Data;
|
} OpenFiles_Data;
|
||||||
|
|
||||||
typedef struct OpenFiles_ProcessData_ {
|
typedef struct OpenFiles_ProcessData_ {
|
||||||
@ -55,6 +57,8 @@ static size_t getIndexForType(char type) {
|
|||||||
return 5;
|
return 5;
|
||||||
case 't':
|
case 't':
|
||||||
return 6;
|
return 6;
|
||||||
|
case 'o':
|
||||||
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* should never reach here */
|
/* should never reach here */
|
||||||
@ -74,7 +78,7 @@ OpenFilesScreen* OpenFilesScreen_new(const Process* process) {
|
|||||||
} else {
|
} else {
|
||||||
this->pid = process->pid;
|
this->pid = process->pid;
|
||||||
}
|
}
|
||||||
return (OpenFilesScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 2, " FD TYPE MODE DEVICE SIZE NODE NAME");
|
return (OpenFilesScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 2, " FD TYPE MODE DEVICE SIZE OFFSET NODE NAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenFilesScreen_delete(Object* this) {
|
void OpenFilesScreen_delete(Object* this) {
|
||||||
@ -115,13 +119,14 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
close(fdnull);
|
close(fdnull);
|
||||||
char buffer[32] = {0};
|
char buffer[32] = {0};
|
||||||
xSnprintf(buffer, sizeof(buffer), "%d", pid);
|
xSnprintf(buffer, sizeof(buffer), "%d", pid);
|
||||||
execlp("lsof", "lsof", "-P", "-p", buffer, "-F", NULL);
|
execlp("lsof", "lsof", "-P", "-o", "-p", buffer, "-F", NULL);
|
||||||
exit(127);
|
exit(127);
|
||||||
}
|
}
|
||||||
close(fdpair[1]);
|
close(fdpair[1]);
|
||||||
|
|
||||||
OpenFiles_Data* item = &(pdata->data);
|
OpenFiles_Data* item = &(pdata->data);
|
||||||
OpenFiles_FileData* fdata = NULL;
|
OpenFiles_FileData* fdata = NULL;
|
||||||
|
bool lsofIncludesFileSize = false;
|
||||||
|
|
||||||
FILE* fd = fdopen(fdpair[0], "r");
|
FILE* fd = fdopen(fdpair[0], "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
@ -155,8 +160,17 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
case 't': /* file's type */
|
case 't': /* file's type */
|
||||||
{
|
{
|
||||||
size_t index = getIndexForType(cmd);
|
size_t index = getIndexForType(cmd);
|
||||||
free(item->data[index]);
|
free_and_xStrdup(&item->data[index], line + 1);
|
||||||
item->data[index] = xStrdup(line + 1);
|
break;
|
||||||
|
}
|
||||||
|
case 'o': /* file's offset */
|
||||||
|
{
|
||||||
|
size_t index = getIndexForType(cmd);
|
||||||
|
if (String_startsWith(line + 1, "0t")) {
|
||||||
|
free_and_xStrdup(&item->data[index], line + 3);
|
||||||
|
} else {
|
||||||
|
free_and_xStrdup(&item->data[index], line + 1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'c': /* process command name */
|
case 'c': /* process command name */
|
||||||
@ -166,7 +180,6 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
case 'k': /* link count */
|
case 'k': /* link count */
|
||||||
case 'l': /* file's lock status */
|
case 'l': /* file's lock status */
|
||||||
case 'L': /* process login name */
|
case 'L': /* process login name */
|
||||||
case 'o': /* file's offset */
|
|
||||||
case 'p': /* process ID */
|
case 'p': /* process ID */
|
||||||
case 'P': /* protocol name */
|
case 'P': /* protocol name */
|
||||||
case 'R': /* parent process ID */
|
case 'R': /* parent process ID */
|
||||||
@ -175,6 +188,10 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
/* ignore */
|
/* ignore */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd == 's')
|
||||||
|
lsofIncludesFileSize = true;
|
||||||
|
|
||||||
free(line);
|
free(line);
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
@ -191,6 +208,25 @@ static OpenFiles_ProcessData* OpenFilesScreen_getProcessData(pid_t pid) {
|
|||||||
pdata->error = WEXITSTATUS(wstatus);
|
pdata->error = WEXITSTATUS(wstatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We got all information we need; no post-processing needed */
|
||||||
|
if (lsofIncludesFileSize)
|
||||||
|
return pdata;
|
||||||
|
|
||||||
|
/* On linux, `lsof -o -F` omits SIZE, so add it back. */
|
||||||
|
/* On macOS, `lsof -o -F` includes SIZE, so this block isn't needed. If no open files have a filesize, this will still run, unfortunately. */
|
||||||
|
size_t fileSizeIndex = getIndexForType('s');
|
||||||
|
for (fdata = pdata->files; fdata != NULL; fdata = fdata->next) {
|
||||||
|
item = &fdata->data;
|
||||||
|
const char* filename = getDataForType(item, 'n');
|
||||||
|
|
||||||
|
struct stat st;
|
||||||
|
if (stat(filename, &st) == 0) {
|
||||||
|
char fileSizeBuf[21]; /* 20 (long long) + 1 (NULL) */
|
||||||
|
xSnprintf(fileSizeBuf, sizeof(fileSizeBuf), "%"PRIu64, st.st_size); /* st.st_size is long long on macOS, long on linux */
|
||||||
|
free_and_xStrdup(&item->data[fileSizeIndex], fileSizeBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return pdata;
|
return pdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,14 +249,15 @@ static void OpenFilesScreen_scan(InfoScreen* this) {
|
|||||||
while (fdata) {
|
while (fdata) {
|
||||||
OpenFiles_Data* data = &fdata->data;
|
OpenFiles_Data* data = &fdata->data;
|
||||||
size_t lenN = strlen(getDataForType(data, 'n'));
|
size_t lenN = strlen(getDataForType(data, 'n'));
|
||||||
size_t sizeEntry = 5 + 7 + 4 + 10 + 10 + 10 + lenN + 7 /*spaces*/ + 1 /*null*/;
|
size_t sizeEntry = 5 + 7 + 4 + 10 + 10 + 10 + 10 + lenN + 8 /*spaces*/ + 1 /*null*/;
|
||||||
char entry[sizeEntry];
|
char entry[sizeEntry];
|
||||||
xSnprintf(entry, sizeof(entry), "%5.5s %-7.7s %-4.4s %-10.10s %10.10s %10.10s %s",
|
xSnprintf(entry, sizeof(entry), "%5.5s %-7.7s %-4.4s %-10.10s %10.10s %10.10s %10.10s %s",
|
||||||
getDataForType(data, 'f'),
|
getDataForType(data, 'f'),
|
||||||
getDataForType(data, 't'),
|
getDataForType(data, 't'),
|
||||||
getDataForType(data, 'a'),
|
getDataForType(data, 'a'),
|
||||||
getDataForType(data, 'D'),
|
getDataForType(data, 'D'),
|
||||||
getDataForType(data, 's'),
|
getDataForType(data, 's'),
|
||||||
|
getDataForType(data, 'o'),
|
||||||
getDataForType(data, 'i'),
|
getDataForType(data, 'i'),
|
||||||
getDataForType(data, 'n'));
|
getDataForType(data, 'n'));
|
||||||
InfoScreen_addLine(this, entry);
|
InfoScreen_addLine(this, entry);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - OpenFilesScreen.h
|
htop - OpenFilesScreen.h
|
||||||
(C) 2005-2006 Hisham H. Muhammad
|
(C) 2005-2006 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - OptionItem.c
|
htop - OptionItem.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - OptionItem.h
|
htop - OptionItem.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
6
Panel.c
6
Panel.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Panel.c
|
htop - Panel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -453,7 +453,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len < 99) {
|
if (len < 99) {
|
||||||
buffer[len] = ch;
|
buffer[len] = (char) ch;
|
||||||
buffer[len + 1] = '\0';
|
buffer[len + 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
|
|||||||
|
|
||||||
// if current word did not match,
|
// if current word did not match,
|
||||||
// retry considering the character the start of a new word.
|
// retry considering the character the start of a new word.
|
||||||
buffer[0] = ch;
|
buffer[0] = (char) ch;
|
||||||
buffer[1] = '\0';
|
buffer[1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
Panel.h
4
Panel.h
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Panel.h
|
htop - Panel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ struct Panel_ {
|
|||||||
int selectedLen;
|
int selectedLen;
|
||||||
void* eventHandlerState;
|
void* eventHandlerState;
|
||||||
int scrollV;
|
int scrollV;
|
||||||
short scrollH;
|
int scrollH;
|
||||||
bool needsRedraw;
|
bool needsRedraw;
|
||||||
bool wasFocus;
|
bool wasFocus;
|
||||||
FunctionBar* currentBar;
|
FunctionBar* currentBar;
|
||||||
|
171
Process.c
171
Process.c
@ -2,7 +2,7 @@
|
|||||||
htop - Process.c
|
htop - Process.c
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -41,17 +41,33 @@ static const char* const kthreadID = "KTHREAD";
|
|||||||
|
|
||||||
static uid_t Process_getuid = (uid_t)-1;
|
static uid_t Process_getuid = (uid_t)-1;
|
||||||
|
|
||||||
int Process_pidDigits = 7;
|
int Process_pidDigits = PROCESS_MIN_PID_DIGITS;
|
||||||
|
int Process_uidDigits = PROCESS_MIN_UID_DIGITS;
|
||||||
|
|
||||||
void Process_setupColumnWidths() {
|
void Process_setupColumnWidths() {
|
||||||
int maxPid = Platform_getMaxPid();
|
int maxPid = Platform_getMaxPid();
|
||||||
if (maxPid == -1)
|
if (maxPid == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (maxPid < (int)pow(10, PROCESS_MIN_PID_DIGITS)) {
|
||||||
|
Process_pidDigits = PROCESS_MIN_PID_DIGITS;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Process_pidDigits = ceil(log10(maxPid));
|
Process_pidDigits = ceil(log10(maxPid));
|
||||||
assert(Process_pidDigits <= PROCESS_MAX_PID_DIGITS);
|
assert(Process_pidDigits <= PROCESS_MAX_PID_DIGITS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Process_setUidColumnWidth(uid_t maxUid) {
|
||||||
|
if (maxUid < (uid_t)pow(10, PROCESS_MIN_UID_DIGITS)) {
|
||||||
|
Process_uidDigits = PROCESS_MIN_UID_DIGITS;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Process_uidDigits = ceil(log10(maxUid));
|
||||||
|
assert(Process_uidDigits <= PROCESS_MAX_UID_DIGITS);
|
||||||
|
}
|
||||||
|
|
||||||
void Process_printBytes(RichString* str, unsigned long long number, bool coloring) {
|
void Process_printBytes(RichString* str, unsigned long long number, bool coloring) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
int len;
|
int len;
|
||||||
@ -399,7 +415,7 @@ void Process_makeCommandStr(Process* this) {
|
|||||||
* - a user thread and showThreadNames is not set */
|
* - a user thread and showThreadNames is not set */
|
||||||
if (Process_isKernelThread(this))
|
if (Process_isKernelThread(this))
|
||||||
return;
|
return;
|
||||||
if (this->state == 'Z' && !this->mergedCommand.str)
|
if (this->state == ZOMBIE && !this->mergedCommand.str)
|
||||||
return;
|
return;
|
||||||
if (Process_isUserlandThread(this) && settings->showThreadNames && (showThreadNames == mc->prevShowThreadNames))
|
if (Process_isUserlandThread(this) && settings->showThreadNames && (showThreadNames == mc->prevShowThreadNames))
|
||||||
return;
|
return;
|
||||||
@ -511,6 +527,12 @@ void Process_makeCommandStr(Process* this) {
|
|||||||
|
|
||||||
if (cmdlineBasenameEnd > cmdlineBasenameStart)
|
if (cmdlineBasenameEnd > cmdlineBasenameStart)
|
||||||
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, baseAttr, CMDLINE_HIGHLIGHT_FLAG_BASENAME);
|
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, baseAttr, CMDLINE_HIGHLIGHT_FLAG_BASENAME);
|
||||||
|
|
||||||
|
if (this->procExeDeleted)
|
||||||
|
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, delExeAttr, CMDLINE_HIGHLIGHT_FLAG_DELETED);
|
||||||
|
else if (this->usesDeletedLib)
|
||||||
|
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, delLibAttr, CMDLINE_HIGHLIGHT_FLAG_DELETED);
|
||||||
|
|
||||||
(void)stpcpyWithNewlineConversion(str, cmdline + (showProgramPath ? 0 : cmdlineBasenameStart));
|
(void)stpcpyWithNewlineConversion(str, cmdline + (showProgramPath ? 0 : cmdlineBasenameStart));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -707,6 +729,48 @@ void Process_printLeftAlignedField(RichString* str, int attr, const char* conten
|
|||||||
RichString_appendChr(str, attr, ' ', width + 1 - columns);
|
RichString_appendChr(str, attr, ' ', width + 1 - columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Process_printPercentage(float val, char* buffer, int n, int* attr) {
|
||||||
|
if (val >= 0) {
|
||||||
|
if (val < 99.9F) {
|
||||||
|
if (val < 0.05F) {
|
||||||
|
*attr = CRT_colors[PROCESS_SHADOW];
|
||||||
|
}
|
||||||
|
xSnprintf(buffer, n, "%4.1f ", val);
|
||||||
|
} else if (val < 999) {
|
||||||
|
*attr = CRT_colors[PROCESS_MEGABYTES];
|
||||||
|
xSnprintf(buffer, n, "%3d. ", (int)val);
|
||||||
|
} else {
|
||||||
|
*attr = CRT_colors[PROCESS_MEGABYTES];
|
||||||
|
xSnprintf(buffer, n, "%4d ", (int)val);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*attr = CRT_colors[PROCESS_SHADOW];
|
||||||
|
xSnprintf(buffer, n, " N/A ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline char processStateChar(ProcessState state) {
|
||||||
|
switch (state) {
|
||||||
|
case UNKNOWN: return '?';
|
||||||
|
case RUNNABLE: return 'U';
|
||||||
|
case RUNNING: return 'R';
|
||||||
|
case QUEUED: return 'Q';
|
||||||
|
case WAITING: return 'W';
|
||||||
|
case UNINTERRUPTIBLE_WAIT: return 'D';
|
||||||
|
case BLOCKED: return 'B';
|
||||||
|
case PAGING: return 'P';
|
||||||
|
case STOPPED: return 'T';
|
||||||
|
case TRACED: return 't';
|
||||||
|
case ZOMBIE: return 'Z';
|
||||||
|
case DEFUNCT: return 'X';
|
||||||
|
case IDLE: return 'I';
|
||||||
|
case SLEEPING: return 'S';
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
return '!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Process_writeField(const Process* this, RichString* str, ProcessField field) {
|
void Process_writeField(const Process* this, RichString* str, ProcessField field) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
size_t n = sizeof(buffer);
|
size_t n = sizeof(buffer);
|
||||||
@ -821,34 +885,13 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
|||||||
|
|
||||||
xSnprintf(buffer, n, "%4ld ", this->nlwp);
|
xSnprintf(buffer, n, "%4ld ", this->nlwp);
|
||||||
break;
|
break;
|
||||||
case PERCENT_CPU:
|
case PERCENT_CPU: Process_printPercentage(this->percent_cpu, buffer, n, &attr); break;
|
||||||
case PERCENT_NORM_CPU: {
|
case PERCENT_NORM_CPU: {
|
||||||
float cpuPercentage = this->percent_cpu;
|
float cpuPercentage = this->percent_cpu / this->processList->activeCPUs;
|
||||||
if (field == PERCENT_NORM_CPU) {
|
Process_printPercentage(cpuPercentage, buffer, n, &attr);
|
||||||
cpuPercentage /= this->processList->activeCPUs;
|
|
||||||
}
|
|
||||||
if (cpuPercentage > 999.9F) {
|
|
||||||
xSnprintf(buffer, n, "%4u ", (unsigned int)cpuPercentage);
|
|
||||||
} else if (cpuPercentage > 99.9F) {
|
|
||||||
xSnprintf(buffer, n, "%3u. ", (unsigned int)cpuPercentage);
|
|
||||||
} else {
|
|
||||||
if (cpuPercentage < 0.05F)
|
|
||||||
attr = CRT_colors[PROCESS_SHADOW];
|
|
||||||
|
|
||||||
xSnprintf(buffer, n, "%4.1f ", cpuPercentage);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PERCENT_MEM:
|
case PERCENT_MEM: Process_printPercentage(this->percent_mem, buffer, n, &attr); break;
|
||||||
if (this->percent_mem > 99.9F) {
|
|
||||||
xSnprintf(buffer, n, "100. ");
|
|
||||||
} else {
|
|
||||||
if (this->percent_mem < 0.05F)
|
|
||||||
attr = CRT_colors[PROCESS_SHADOW];
|
|
||||||
|
|
||||||
xSnprintf(buffer, n, "%4.1f ", this->percent_mem);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PGRP: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pgrp); break;
|
case PGRP: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pgrp); break;
|
||||||
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pid); break;
|
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pid); break;
|
||||||
case PPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->ppid); break;
|
case PPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->ppid); break;
|
||||||
@ -862,21 +905,35 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
|||||||
case SESSION: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->session); break;
|
case SESSION: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->session); break;
|
||||||
case STARTTIME: xSnprintf(buffer, n, "%s", this->starttime_show); break;
|
case STARTTIME: xSnprintf(buffer, n, "%s", this->starttime_show); break;
|
||||||
case STATE:
|
case STATE:
|
||||||
xSnprintf(buffer, n, "%c ", this->state);
|
xSnprintf(buffer, n, "%c ", processStateChar(this->state));
|
||||||
switch (this->state) {
|
switch (this->state) {
|
||||||
case 'R':
|
case RUNNABLE:
|
||||||
attr = CRT_colors[PROCESS_R_STATE];
|
case RUNNING:
|
||||||
|
case TRACED:
|
||||||
|
attr = CRT_colors[PROCESS_RUN_STATE];
|
||||||
break;
|
break;
|
||||||
case 'D':
|
|
||||||
|
case BLOCKED:
|
||||||
|
case DEFUNCT:
|
||||||
|
case STOPPED:
|
||||||
|
case ZOMBIE:
|
||||||
attr = CRT_colors[PROCESS_D_STATE];
|
attr = CRT_colors[PROCESS_D_STATE];
|
||||||
break;
|
break;
|
||||||
case 'I':
|
|
||||||
case 'S':
|
case QUEUED:
|
||||||
|
case WAITING:
|
||||||
|
case UNINTERRUPTIBLE_WAIT:
|
||||||
|
case IDLE:
|
||||||
|
case SLEEPING:
|
||||||
attr = CRT_colors[PROCESS_SHADOW];
|
attr = CRT_colors[PROCESS_SHADOW];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case UNKNOWN:
|
||||||
|
case PAGING:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ST_UID: xSnprintf(buffer, n, "%5d ", this->st_uid); break;
|
case ST_UID: xSnprintf(buffer, n, "%*d ", Process_uidDigits, this->st_uid); break;
|
||||||
case TIME: Process_printTime(str, this->time, coloring); return;
|
case TIME: Process_printTime(str, this->time, coloring); return;
|
||||||
case TGID:
|
case TGID:
|
||||||
if (this->tgid == this->pid)
|
if (this->tgid == this->pid)
|
||||||
@ -899,11 +956,11 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
|||||||
attr = CRT_colors[PROCESS_SHADOW];
|
attr = CRT_colors[PROCESS_SHADOW];
|
||||||
|
|
||||||
if (this->user) {
|
if (this->user) {
|
||||||
Process_printLeftAlignedField(str, attr, this->user, 9);
|
Process_printLeftAlignedField(str, attr, this->user, 10);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
xSnprintf(buffer, n, "%-9d ", this->st_uid);
|
xSnprintf(buffer, n, "%-10d ", this->st_uid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (DynamicColumn_writeField(this, str, field))
|
if (DynamicColumn_writeField(this, str, field))
|
||||||
@ -1047,44 +1104,6 @@ int Process_compare(const void* v1, const void* v2) {
|
|||||||
return (Settings_getActiveDirection(settings) == 1) ? result : -result;
|
return (Settings_getActiveDirection(settings) == 1) ? result : -result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t stateCompareValue(char state) {
|
|
||||||
switch (state) {
|
|
||||||
|
|
||||||
case 'S':
|
|
||||||
return 10;
|
|
||||||
|
|
||||||
case 'I':
|
|
||||||
return 9;
|
|
||||||
|
|
||||||
case 'X':
|
|
||||||
return 8;
|
|
||||||
|
|
||||||
case 'Z':
|
|
||||||
return 7;
|
|
||||||
|
|
||||||
case 't':
|
|
||||||
return 6;
|
|
||||||
|
|
||||||
case 'T':
|
|
||||||
return 5;
|
|
||||||
|
|
||||||
case 'L':
|
|
||||||
return 4;
|
|
||||||
|
|
||||||
case 'D':
|
|
||||||
return 3;
|
|
||||||
|
|
||||||
case 'R':
|
|
||||||
return 2;
|
|
||||||
|
|
||||||
case '?':
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField key) {
|
int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField key) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -1139,7 +1158,7 @@ int Process_compareByKey_Base(const Process* p1, const Process* p2, ProcessField
|
|||||||
r = SPACESHIP_NUMBER(p1->starttime_ctime, p2->starttime_ctime);
|
r = SPACESHIP_NUMBER(p1->starttime_ctime, p2->starttime_ctime);
|
||||||
return r != 0 ? r : SPACESHIP_NUMBER(p1->pid, p2->pid);
|
return r != 0 ? r : SPACESHIP_NUMBER(p1->pid, p2->pid);
|
||||||
case STATE:
|
case STATE:
|
||||||
return SPACESHIP_NUMBER(stateCompareValue(p1->state), stateCompareValue(p2->state));
|
return SPACESHIP_NUMBER(p1->state, p2->state);
|
||||||
case ST_UID:
|
case ST_UID:
|
||||||
return SPACESHIP_NUMBER(p1->st_uid, p2->st_uid);
|
return SPACESHIP_NUMBER(p1->st_uid, p2->st_uid);
|
||||||
case TIME:
|
case TIME:
|
||||||
|
49
Process.h
49
Process.h
@ -4,7 +4,7 @@
|
|||||||
htop - Process.h
|
htop - Process.h
|
||||||
(C) 2004-2015 Hisham H. Muhammad
|
(C) 2004-2015 Hisham H. Muhammad
|
||||||
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
(C) 2020 Red Hat, Inc. All Rights Reserved.
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -60,6 +60,26 @@ typedef enum ProcessField_ {
|
|||||||
LAST_PROCESSFIELD
|
LAST_PROCESSFIELD
|
||||||
} ProcessField;
|
} ProcessField;
|
||||||
|
|
||||||
|
/* Core process states (shared by platforms)
|
||||||
|
* NOTE: The enum has an ordering that is important!
|
||||||
|
* See processStateChar in process.c for ProcessSate -> letter mapping */
|
||||||
|
typedef enum ProcessState_ {
|
||||||
|
UNKNOWN = 1,
|
||||||
|
RUNNABLE,
|
||||||
|
RUNNING,
|
||||||
|
QUEUED,
|
||||||
|
WAITING,
|
||||||
|
UNINTERRUPTIBLE_WAIT,
|
||||||
|
BLOCKED,
|
||||||
|
PAGING,
|
||||||
|
STOPPED,
|
||||||
|
TRACED,
|
||||||
|
ZOMBIE,
|
||||||
|
DEFUNCT,
|
||||||
|
IDLE,
|
||||||
|
SLEEPING
|
||||||
|
} ProcessState;
|
||||||
|
|
||||||
struct Settings_;
|
struct Settings_;
|
||||||
|
|
||||||
/* Holds information about regions of the cmdline that should be
|
/* Holds information about regions of the cmdline that should be
|
||||||
@ -79,8 +99,6 @@ typedef struct ProcessMergedCommand_ {
|
|||||||
char* str; /* merged Command string */
|
char* str; /* merged Command string */
|
||||||
size_t highlightCount; /* how many portions of cmdline to highlight */
|
size_t highlightCount; /* how many portions of cmdline to highlight */
|
||||||
ProcessCmdlineHighlight highlights[8]; /* which portions of cmdline to highlight */
|
ProcessCmdlineHighlight highlights[8]; /* which portions of cmdline to highlight */
|
||||||
bool separateComm : 1; /* whether comm is a separate field */
|
|
||||||
bool unmatchedExe : 1; /* whether exe matched with cmdline */
|
|
||||||
bool cmdlineChanged : 1; /* whether cmdline changed */
|
bool cmdlineChanged : 1; /* whether cmdline changed */
|
||||||
bool exeChanged : 1; /* whether exe changed */
|
bool exeChanged : 1; /* whether exe changed */
|
||||||
bool commChanged : 1; /* whether comm changed */
|
bool commChanged : 1; /* whether comm changed */
|
||||||
@ -204,20 +222,8 @@ typedef struct Process_ {
|
|||||||
/* Number of major faults the process has made which have required loading a memory page from disk */
|
/* Number of major faults the process has made which have required loading a memory page from disk */
|
||||||
unsigned long int majflt;
|
unsigned long int majflt;
|
||||||
|
|
||||||
/*
|
/* Process state enum field (platform dependent) */
|
||||||
* Process state (platform dependent):
|
ProcessState state;
|
||||||
* D - Waiting
|
|
||||||
* I - Idle
|
|
||||||
* L - Acquiring lock
|
|
||||||
* R - Running
|
|
||||||
* S - Sleeping
|
|
||||||
* T - Stopped (on a signal)
|
|
||||||
* X - Dead
|
|
||||||
* Z - Zombie
|
|
||||||
* t - Tracing stop
|
|
||||||
* ? - Unknown
|
|
||||||
*/
|
|
||||||
char state;
|
|
||||||
|
|
||||||
/* Whether the process was updated during the current scan */
|
/* Whether the process was updated during the current scan */
|
||||||
bool updated;
|
bool updated;
|
||||||
@ -280,8 +286,12 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
|
|||||||
int Process_compare(const void* v1, const void* v2);
|
int Process_compare(const void* v1, const void* v2);
|
||||||
void Process_delete(Object* cast);
|
void Process_delete(Object* cast);
|
||||||
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
|
||||||
|
#define PROCESS_MIN_PID_DIGITS 5
|
||||||
#define PROCESS_MAX_PID_DIGITS 19
|
#define PROCESS_MAX_PID_DIGITS 19
|
||||||
|
#define PROCESS_MIN_UID_DIGITS 5
|
||||||
|
#define PROCESS_MAX_UID_DIGITS 19
|
||||||
extern int Process_pidDigits;
|
extern int Process_pidDigits;
|
||||||
|
extern int Process_uidDigits;
|
||||||
|
|
||||||
typedef Process* (*Process_New)(const struct Settings_*);
|
typedef Process* (*Process_New)(const struct Settings_*);
|
||||||
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
|
typedef void (*Process_WriteField)(const Process*, RichString*, ProcessField);
|
||||||
@ -339,6 +349,9 @@ static inline bool Process_isThread(const Process* this) {
|
|||||||
|
|
||||||
void Process_setupColumnWidths(void);
|
void Process_setupColumnWidths(void);
|
||||||
|
|
||||||
|
/* Sets the size of the UID column based on the passed UID */
|
||||||
|
void Process_setUidColumnWidth(uid_t maxUid);
|
||||||
|
|
||||||
/* Takes number in bytes (base 1024). Prints 6 columns. */
|
/* Takes number in bytes (base 1024). Prints 6 columns. */
|
||||||
void Process_printBytes(RichString* str, unsigned long long number, bool coloring);
|
void Process_printBytes(RichString* str, unsigned long long number, bool coloring);
|
||||||
|
|
||||||
@ -358,6 +371,8 @@ void Process_fillStarttimeBuffer(Process* this);
|
|||||||
|
|
||||||
void Process_printLeftAlignedField(RichString* str, int attr, const char* content, unsigned int width);
|
void Process_printLeftAlignedField(RichString* str, int attr, const char* content, unsigned int width);
|
||||||
|
|
||||||
|
void Process_printPercentage(float val, char* buffer, int n, int* attr);
|
||||||
|
|
||||||
void Process_display(const Object* cast, RichString* out);
|
void Process_display(const Object* cast, RichString* out);
|
||||||
|
|
||||||
void Process_done(Process* this);
|
void Process_done(Process* this);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ProcessList.c
|
htop - ProcessList.c
|
||||||
(C) 2004,2005 Hisham H. Muhammad
|
(C) 2004,2005 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -105,13 +105,19 @@ static const char* alignedProcessFieldTitle(const ProcessList* this, ProcessFiel
|
|||||||
if (!title)
|
if (!title)
|
||||||
return "- ";
|
return "- ";
|
||||||
|
|
||||||
if (!Process_fields[field].pidColumn)
|
if (Process_fields[field].pidColumn) {
|
||||||
return title;
|
static char titleBuffer[PROCESS_MAX_PID_DIGITS + sizeof(" ")];
|
||||||
|
xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_pidDigits, title);
|
||||||
|
return titleBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
static char titleBuffer[PROCESS_MAX_PID_DIGITS + /* space */ 1 + /* null-terminator */ + 1];
|
if (field == ST_UID) {
|
||||||
xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_pidDigits, title);
|
static char titleBuffer[PROCESS_MAX_UID_DIGITS + sizeof(" ")];
|
||||||
|
xSnprintf(titleBuffer, sizeof(titleBuffer), "%*s ", Process_uidDigits, title);
|
||||||
|
return titleBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
return titleBuffer;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessList_printHeader(const ProcessList* this, RichString* header) {
|
void ProcessList_printHeader(const ProcessList* this, RichString* header) {
|
||||||
@ -626,10 +632,15 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) {
|
|||||||
|
|
||||||
ProcessList_goThroughEntries(this, false);
|
ProcessList_goThroughEntries(this, false);
|
||||||
|
|
||||||
|
uid_t maxUid = 0;
|
||||||
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
|
for (int i = Vector_size(this->processes) - 1; i >= 0; i--) {
|
||||||
Process* p = (Process*) Vector_get(this->processes, i);
|
Process* p = (Process*) Vector_get(this->processes, i);
|
||||||
Process_makeCommandStr(p);
|
Process_makeCommandStr(p);
|
||||||
|
|
||||||
|
// keep track of the highest UID for column scaling
|
||||||
|
if (p->st_uid > maxUid)
|
||||||
|
maxUid = p->st_uid;
|
||||||
|
|
||||||
if (p->tombStampMs > 0) {
|
if (p->tombStampMs > 0) {
|
||||||
// remove tombed process
|
// remove tombed process
|
||||||
if (this->monotonicMs >= p->tombStampMs) {
|
if (this->monotonicMs >= p->tombStampMs) {
|
||||||
@ -647,6 +658,9 @@ void ProcessList_scan(ProcessList* this, bool pauseProcessUpdate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set UID column width based on max UID.
|
||||||
|
Process_setUidColumnWidth(maxUid);
|
||||||
|
|
||||||
if (this->settings->treeView) {
|
if (this->settings->treeView) {
|
||||||
// Clear out the hashtable to avoid any left-over processes from previous build
|
// Clear out the hashtable to avoid any left-over processes from previous build
|
||||||
//
|
//
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ProcessList.h
|
htop - ProcessList.h
|
||||||
(C) 2004,2005 Hisham H. Muhammad
|
(C) 2004,2005 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ProcessLocksScreen.c
|
htop - ProcessLocksScreen.c
|
||||||
(C) 2020 htop dev team
|
(C) 2020 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ProcessLocksScreen.h
|
htop - ProcessLocksScreen.h
|
||||||
(C) 2020 htop dev team
|
(C) 2020 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - RichString.h
|
htop - RichString.h
|
||||||
(C) 2004,2011 Hisham H. Muhammad
|
(C) 2004,2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
114
README
114
README
@ -1,10 +1,12 @@
|
|||||||
# [](https://htop.dev)
|
# [](https://htop.dev)
|
||||||
|
|
||||||
[](https://github.com/htop-dev/htop/actions)
|
[](https://github.com/htop-dev/htop/actions)
|
||||||
[](https://scan.coverity.com/projects/21665)
|
[](https://scan.coverity.com/projects/21665)
|
||||||
[](https://groups.io/g/htop)
|
[](https://groups.io/g/htop)
|
||||||
[](https://web.libera.chat/#htop)
|
[](https://web.libera.chat/#htop)
|
||||||
[](https://github.com/htop-dev/htop/releases/latest)
|
[](https://github.com/htop-dev/htop/releases/latest)
|
||||||
|
[](https://repology.org/project/htop/versions)
|
||||||
|
[](COPYING?raw=true)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -13,26 +15,30 @@
|
|||||||
`htop` is a cross-platform interactive process viewer.
|
`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.
|
`htop` allows scrolling the list of processes vertically and horizontally to see their full command lines and related information like memory and CPU consumption.
|
||||||
|
Also system wide information, like load average or swap usage, is shown.
|
||||||
|
|
||||||
The information displayed is configurable through a graphical setup and can be sorted and filtered interactively.
|
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.
|
Tasks related to processes (e.g. killing and renicing) can be done without entering their PIDs.
|
||||||
|
|
||||||
Running `htop` requires `ncurses` libraries (typically named libncursesw*).
|
Running `htop` requires `ncurses` libraries, typically named libncurses(w).
|
||||||
|
|
||||||
For more information and details on how to contribute to `htop` visit [htop.dev](https://htop.dev).
|
`htop` is written in C.
|
||||||
|
|
||||||
|
For more information and details visit [htop.dev](https://htop.dev).
|
||||||
|
|
||||||
## Build instructions
|
## Build instructions
|
||||||
|
|
||||||
### Prerequisite
|
### Prerequisite
|
||||||
List of build-time dependencies:
|
List of build-time dependencies:
|
||||||
* `build-essential` standard GNU autotools-based
|
* standard GNU autotools-based C toolchain
|
||||||
* `autoconf`
|
- C99 compliant compiler
|
||||||
* `autotools`
|
- `autoconf`
|
||||||
* `ncurses`
|
- `autotools`
|
||||||
|
* `ncurses`
|
||||||
|
|
||||||
**Note about `ncurses`:**
|
**Note about `ncurses`:**
|
||||||
> htop requires ncurses 6.0. Be aware the appropriate package is sometimes still called libncurses5 (on Debian/Ubuntu). Also ncurses usually comes in two flavours:
|
> `htop` requires `ncurses` 6.0. Be aware the appropriate package is sometimes still called libncurses5 (on Debian/Ubuntu). Also `ncurses` usually comes in two flavours:
|
||||||
>* With Unicode support.
|
>* With Unicode support.
|
||||||
>* Without Unicode support.
|
>* Without Unicode support.
|
||||||
>
|
>
|
||||||
@ -41,28 +47,27 @@ List of build-time dependencies:
|
|||||||
List of additional build-time dependencies (based on feature flags):
|
List of additional build-time dependencies (based on feature flags):
|
||||||
* `sensors`
|
* `sensors`
|
||||||
* `hwloc`
|
* `hwloc`
|
||||||
* `libcap`
|
* `libcap` (v2.21 or later)
|
||||||
|
* `libnl-3`
|
||||||
|
|
||||||
Compiling `htop` requires the header files for `ncurses` . Install these and other required packages for C development from your package manager.
|
Install these and other required packages for C development from your package manager.
|
||||||
|
|
||||||
**Debian/Ubuntu**
|
**Debian/Ubuntu**
|
||||||
~~~ shell
|
~~~ shell
|
||||||
sudo apt install libncursesw5-dev autotools-dev autoconf
|
sudo apt install libncursesw5-dev autotools-dev autoconf build-essential
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
**Fedora/RHEL**
|
**Fedora/RHEL**
|
||||||
~~~ shell
|
~~~ shell
|
||||||
sudo dnf install ncurses-devel automake autoconf
|
sudo dnf install ncurses-devel automake autoconf gcc
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
### Compiling from source:
|
### Compile from source:
|
||||||
To compile from sources downloaded from the Git repository (`git clone` or downloads from [Github releases](https://github.com/htop-dev/htop/releases/)), then run:
|
To compile from source, download from the Git repository (`git clone` or downloads from [GitHub releases](https://github.com/htop-dev/htop/releases/)), then run:
|
||||||
~~~ shell
|
~~~ shell
|
||||||
./autogen.sh && ./configure && make
|
./autogen.sh && ./configure && make
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
By default `make install` will install into `/usr/local`, for changing the path use `./configure --prefix=/some/path`.
|
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
To install on the local system run `make install`. By default `make install` installs into `/usr/local`. To change this path use `./configure --prefix=/some/path`.
|
To install on the local system run `make install`. By default `make install` installs into `/usr/local`. To change this path use `./configure --prefix=/some/path`.
|
||||||
|
|
||||||
@ -74,52 +79,55 @@ To install on the local system run `make install`. By default `make install` ins
|
|||||||
|
|
||||||
* `--enable-unicode`:
|
* `--enable-unicode`:
|
||||||
enable Unicode support
|
enable Unicode support
|
||||||
dependency: *libncursesw*
|
- dependency: *libncursesw*
|
||||||
default: *yes*
|
- default: *yes*
|
||||||
* `--enable-pcp`:
|
|
||||||
enable Performance Co-Pilot support via a new pcp-htop utility
|
|
||||||
dependency: *libpcp*
|
|
||||||
default: *no*
|
|
||||||
* `--enable-affinity`:
|
* `--enable-affinity`:
|
||||||
enable `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc
|
enable `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc
|
||||||
default: *check*
|
- default: *check*
|
||||||
* `--enable-hwloc`:
|
* `--enable-hwloc`:
|
||||||
enable hwloc support for CPU affinity; disables affinity support
|
enable hwloc support for CPU affinity; disables affinity support
|
||||||
dependency: *libhwloc*
|
- dependency: *libhwloc*
|
||||||
default: *no*
|
- default: *no*
|
||||||
* `--enable-static`:
|
* `--enable-static`:
|
||||||
build a static htop binary; hwloc and delay accounting are not supported
|
build a static htop binary; hwloc and delay accounting are not supported
|
||||||
default: *no*
|
- default: *no*
|
||||||
* `--enable-debug`:
|
* `--enable-debug`:
|
||||||
Enable asserts and internal sanity checks; implies a performance penalty
|
Enable asserts and internal sanity checks; implies a performance penalty
|
||||||
default: *no*
|
- default: *no*
|
||||||
|
|
||||||
|
#### Performance Co-Pilot
|
||||||
|
|
||||||
|
* `--enable-pcp`:
|
||||||
|
enable Performance Co-Pilot support via a new pcp-htop utility
|
||||||
|
- dependency: *libpcp*
|
||||||
|
- default: *no*
|
||||||
|
|
||||||
#### Linux
|
#### Linux
|
||||||
|
|
||||||
* `--enable-sensors`:
|
* `--enable-sensors`:
|
||||||
enable libsensors(3) support for reading temperature data
|
enable libsensors(3) support for reading temperature data
|
||||||
dependencies: *libsensors-dev*(build-time), at runtime *libsensors* is loaded via `dlopen(3)` if available
|
- dependencies: *libsensors-dev*(build-time), at runtime *libsensors* is loaded via `dlopen(3)` if available
|
||||||
default: *check*
|
- default: *check*
|
||||||
* `--enable-capabilities`:
|
* `--enable-capabilities`:
|
||||||
enable Linux capabilities support
|
enable Linux capabilities support
|
||||||
dependency: *libcap*
|
- dependency: *libcap*
|
||||||
default: *check*
|
- default: *check*
|
||||||
* `--with-proc`:
|
* `--with-proc`:
|
||||||
location of a Linux-compatible proc filesystem
|
location of a Linux-compatible proc filesystem
|
||||||
default: */proc*
|
- default: */proc*
|
||||||
* `--enable-openvz`:
|
* `--enable-openvz`:
|
||||||
enable OpenVZ support
|
enable OpenVZ support
|
||||||
default: *no*
|
- default: *no*
|
||||||
* `--enable-vserver`:
|
* `--enable-vserver`:
|
||||||
enable VServer support
|
enable VServer support
|
||||||
default: *no*
|
- default: *no*
|
||||||
* `--enable-ancient-vserver`:
|
* `--enable-ancient-vserver`:
|
||||||
enable ancient VServer support (implies `--enable-vserver`)
|
enable ancient VServer support (implies `--enable-vserver`)
|
||||||
default: *no*
|
- default: *no*
|
||||||
* `--enable-delayacct`:
|
* `--enable-delayacct`:
|
||||||
enable Linux delay accounting support
|
enable Linux delay accounting support
|
||||||
dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3*
|
- dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3*
|
||||||
default: *check*
|
- default: *check*
|
||||||
|
|
||||||
|
|
||||||
## Runtime dependencies:
|
## Runtime dependencies:
|
||||||
@ -128,40 +136,42 @@ To install on the local system run `make install`. By default `make install` ins
|
|||||||
|
|
||||||
### Runtime optional dependencies:
|
### Runtime optional dependencies:
|
||||||
`htop` has a set of fixed optional dependencies, depending on build/configure option used:
|
`htop` has a set of fixed optional dependencies, depending on build/configure option used:
|
||||||
* `libdl`, if not building static and support for some of the optional libraries is enabled, is always required when support for to optionally load dependencies (i.e. `libsensors`, `systemd`) is present.
|
|
||||||
* `libcap`, user-space interfaces to the POSIX 1003.1e, is always required when `--enable-capabilities` was used to configure `htop`.
|
#### Linux
|
||||||
|
* `libdl`, if not building a static binary, is always required when support for optional dependencies (i.e. `libsensors`, `libsystemd`) is present.
|
||||||
|
* `libcap`, user-space interfaces to POSIX 1003.1e capabilities, is always required when `--enable-capabilities` was used to configure `htop`.
|
||||||
* `libsensors`, readout of temperatures and CPU speeds, is optional even when `--enable-sensors` was used to configure `htop`.
|
* `libsensors`, readout of temperatures and CPU speeds, is optional even when `--enable-sensors` was used to configure `htop`.
|
||||||
* `systemd` is optional when `--enable-static` was not used to configure `htop` (Linux only). If building statically and `libsystemd` is not found by `configure` support for the SystemD meter is disabled entirely.
|
* `libsystemd` is optional when `--enable-static` was not used to configure `htop`. If building statically and `libsystemd` is not found by `configure`, support for the systemd meter is disabled entirely.
|
||||||
|
|
||||||
`htop` checks for the availability of the actual runtime lib as `htop` runs.
|
`htop` checks for the availability of the actual runtime libraries as `htop` runs.
|
||||||
|
|
||||||
**BSD**
|
#### BSD
|
||||||
On most *BSD systems you also have `kvm` as a static requirement to read all the kernel information.
|
On most BSD systems `kvm` is a requirement to read kernel information.
|
||||||
|
|
||||||
More information on required and optional dependencies can be found in [configure.ac](configure.ac).
|
More information on required and optional dependencies can be found in [configure.ac](configure.ac).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
See the manual page (`man htop`) or the on-line help ('F1' or 'h' inside `htop`) for a list of supported key commands.
|
See the manual page (`man htop`) or the help menu (**F1** or **h** inside `htop`) for a list of supported key commands.
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
If you have trouble running `htop` please consult your Operating System / Linux distribution documentation for getting support and filing bugs.
|
If you have trouble running `htop` please consult your operating system / Linux distribution documentation for getting support and filing bugs.
|
||||||
|
|
||||||
## Bugs, development feedback
|
## Bugs, development feedback
|
||||||
|
|
||||||
We have a [development mailing list](https://htop.dev/mailinglist.html). Feel free to subscribe for release announcements or asking questions on the development of htop.
|
We have a [development mailing list](https://htop.dev/mailinglist.html). Feel free to subscribe for release announcements or asking questions on the development of `htop`.
|
||||||
|
|
||||||
You can also join our IRC channel #htop on Libera.Chat and talk to the developers there.
|
You can also join our IRC channel [#htop on Libera.Chat](https://web.libera.chat/#htop) 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](https://github.com/htop-dev/htop/issues).
|
If you have found an issue within the source of `htop`, please check whether this has already been reported in our [GitHub issue tracker](https://github.com/htop-dev/htop/issues).
|
||||||
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.
|
If not, please file a new issue describing the problem you have found, the potential location in the source code you are referring to and a possible fix if available.
|
||||||
|
|
||||||
## History
|
## History
|
||||||
|
|
||||||
`htop` was invented, developed and maintained by Hisham Muhammad from 2004 to 2019. His [legacy repository](https://github.com/hishamhm/htop/) has been archived to preserve the history.
|
`htop` was invented, developed and maintained by [Hisham Muhammad](https://hisham.hm/) from 2004 to 2019. His [legacy repository](https://github.com/hishamhm/htop/) has been archived to preserve the history.
|
||||||
|
|
||||||
In 2020 a [team](https://github.com/orgs/htop-dev/people) took over the development amicably and continues to maintain `htop` collaboratively.
|
In 2020 a [team](https://github.com/orgs/htop-dev/people) took over the development amicably and continues to maintain `htop` collaboratively.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GNU General Public License, version 2 (GPL-2.0)
|
GNU General Public License, version 2 (GPL-2.0) or, at your option, any later version.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - RichString.c
|
htop - RichString.c
|
||||||
(C) 2004,2011 Hisham H. Muhammad
|
(C) 2004,2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - RichString.h
|
htop - RichString.h
|
||||||
(C) 2004,2011 Hisham H. Muhammad
|
(C) 2004,2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ScreenManager.c
|
htop - ScreenManager.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ void ScreenManager_resize(ScreenManager* this) {
|
|||||||
Panel_move(panel, lastX, y1_header);
|
Panel_move(panel, lastX, y1_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut) {
|
static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTimeout, bool* redraw, bool* rescan, bool* timedOut, bool *force_redraw) {
|
||||||
ProcessList* pl = this->header->pl;
|
ProcessList* pl = this->header->pl;
|
||||||
|
|
||||||
Platform_gettime_realtime(&pl->realtime, &pl->realtimeMs);
|
Platform_gettime_realtime(&pl->realtime, &pl->realtimeMs);
|
||||||
@ -103,6 +103,7 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
|
|||||||
|
|
||||||
if (*rescan) {
|
if (*rescan) {
|
||||||
*oldTime = newTime;
|
*oldTime = newTime;
|
||||||
|
int oldUidDigits = Process_uidDigits;
|
||||||
// scan processes first - some header values are calculated there
|
// scan processes first - some header values are calculated there
|
||||||
ProcessList_scan(pl, this->state->pauseProcessUpdate);
|
ProcessList_scan(pl, this->state->pauseProcessUpdate);
|
||||||
// always update header, especially to avoid gaps in graph meters
|
// always update header, especially to avoid gaps in graph meters
|
||||||
@ -111,6 +112,10 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
|
|||||||
ProcessList_sort(pl);
|
ProcessList_sort(pl);
|
||||||
*sortTimeout = 1;
|
*sortTimeout = 1;
|
||||||
}
|
}
|
||||||
|
// force redraw if the number of UID digits was changed
|
||||||
|
if (Process_uidDigits != oldUidDigits) {
|
||||||
|
*force_redraw = true;
|
||||||
|
}
|
||||||
*redraw = true;
|
*redraw = true;
|
||||||
}
|
}
|
||||||
if (*redraw) {
|
if (*redraw) {
|
||||||
@ -153,7 +158,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
|||||||
|
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
if (this->header) {
|
if (this->header) {
|
||||||
checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut);
|
checkRecalculation(this, &oldTime, &sortTimeout, &redraw, &rescan, &timedOut, &force_redraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redraw || force_redraw) {
|
if (redraw || force_redraw) {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - ScreenManager.h
|
htop - ScreenManager.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
72
Settings.c
72
Settings.c
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Settings.c
|
htop - Settings.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -28,11 +28,7 @@ void Settings_delete(Settings* this) {
|
|||||||
free(this->filename);
|
free(this->filename);
|
||||||
free(this->fields);
|
free(this->fields);
|
||||||
for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) {
|
for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) {
|
||||||
if (this->hColumns[i].names) {
|
String_freeArray(this->hColumns[i].names);
|
||||||
for (uint8_t j = 0; j < this->hColumns[i].len; j++)
|
|
||||||
free(this->hColumns[i].names[j]);
|
|
||||||
free(this->hColumns[i].names);
|
|
||||||
}
|
|
||||||
free(this->hColumns[i].modes);
|
free(this->hColumns[i].modes);
|
||||||
}
|
}
|
||||||
free(this->hColumns);
|
free(this->hColumns);
|
||||||
@ -65,16 +61,51 @@ static void Settings_readMeterModes(Settings* this, const char* line, unsigned i
|
|||||||
this->hColumns[column].modes = modes;
|
this->hColumns[column].modes = modes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool Settings_validateMeters(Settings* this) {
|
||||||
|
const size_t colCount = HeaderLayout_getColumns(this->hLayout);
|
||||||
|
|
||||||
|
for (size_t column = 0; column < colCount; column++) {
|
||||||
|
char** names = this->hColumns[column].names;
|
||||||
|
const int* modes = this->hColumns[column].modes;
|
||||||
|
const size_t len = this->hColumns[column].len;
|
||||||
|
|
||||||
|
if (!names || !modes || !len)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check for each mode there is an entry with a non-NULL name
|
||||||
|
for (size_t meterIdx = 0; meterIdx < len; meterIdx++)
|
||||||
|
if (!names[meterIdx])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (names[len])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount) {
|
static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount) {
|
||||||
int sizes[] = { 3, 3 };
|
int sizes[] = { 3, 3 };
|
||||||
|
|
||||||
if (initialCpuCount > 4 && initialCpuCount <= 128) {
|
if (initialCpuCount > 4 && initialCpuCount <= 128) {
|
||||||
sizes[1]++;
|
sizes[1]++;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
|
// Release any previously allocated memory
|
||||||
|
for (size_t i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) {
|
||||||
|
String_freeArray(this->hColumns[i].names);
|
||||||
|
free(this->hColumns[i].modes);
|
||||||
|
}
|
||||||
|
free(this->hColumns);
|
||||||
|
|
||||||
|
this->hLayout = HF_TWO_50_50;
|
||||||
|
this->hColumns = xCalloc(HeaderLayout_getColumns(this->hLayout), sizeof(MeterColumnSetting));
|
||||||
|
for (size_t i = 0; i < 2; i++) {
|
||||||
this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(char*));
|
this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(char*));
|
||||||
this->hColumns[i].modes = xCalloc(sizes[i], sizeof(int));
|
this->hColumns[i].modes = xCalloc(sizes[i], sizeof(int));
|
||||||
this->hColumns[i].len = sizes[i];
|
this->hColumns[i].len = sizes[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (initialCpuCount > 128) {
|
if (initialCpuCount > 128) {
|
||||||
@ -134,8 +165,9 @@ static void Settings_readFields(Settings* settings, const char* line) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dynamically-defined columns are always stored by-name.
|
// Dynamically-defined columns are always stored by-name.
|
||||||
char* end, dynamic[32] = {0};
|
char dynamic[32] = {0};
|
||||||
if (sscanf(ids[i], "Dynamic(%30s)", dynamic)) {
|
if (sscanf(ids[i], "Dynamic(%30s)", dynamic)) {
|
||||||
|
char* end;
|
||||||
if ((end = strrchr(dynamic, ')')) == NULL)
|
if ((end = strrchr(dynamic, ')')) == NULL)
|
||||||
continue;
|
continue;
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
@ -180,8 +212,11 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
|
|||||||
this->config_version = atoi(option[1]);
|
this->config_version = atoi(option[1]);
|
||||||
if (this->config_version > CONFIG_READER_MIN_VERSION) {
|
if (this->config_version > CONFIG_READER_MIN_VERSION) {
|
||||||
// the version of the config file on disk is newer than what we can read
|
// the version of the config file on disk is newer than what we can read
|
||||||
fprintf(stderr, "WARNING: %s specifies configuration format version v%d, but this %s binary supports up to v%d.", fileName, this->config_version, PACKAGE, CONFIG_READER_MIN_VERSION);
|
fprintf(stderr, "WARNING: %s specifies configuration format\n", fileName);
|
||||||
fprintf(stderr, " The configuration version will be downgraded to v%d when %s exits.\n", CONFIG_READER_MIN_VERSION, PACKAGE);
|
fprintf(stderr, " version v%d, but this %s binary only supports up to version v%d.\n", this->config_version, PACKAGE, CONFIG_READER_MIN_VERSION);
|
||||||
|
fprintf(stderr, " The configuration file will be downgraded to v%d when %s exits.\n", CONFIG_READER_MIN_VERSION, PACKAGE);
|
||||||
|
String_freeArray(option);
|
||||||
|
fclose(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (String_eq(option[0], "fields")) {
|
} else if (String_eq(option[0], "fields")) {
|
||||||
@ -301,7 +336,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
|
|||||||
String_freeArray(option);
|
String_freeArray(option);
|
||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
if (!didReadMeters) {
|
if (!didReadMeters || !Settings_validateMeters(this)) {
|
||||||
Settings_defaultMeters(this, initialCpuCount);
|
Settings_defaultMeters(this, initialCpuCount);
|
||||||
}
|
}
|
||||||
return didReadAny;
|
return didReadAny;
|
||||||
@ -325,7 +360,7 @@ static void writeFields(FILE* fd, const ProcessField* fields, Hashtable* columns
|
|||||||
|
|
||||||
static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned int column) {
|
static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned int column) {
|
||||||
const char* sep = "";
|
const char* sep = "";
|
||||||
for (uint8_t i = 0; i < this->hColumns[column].len; i++) {
|
for (size_t i = 0; i < this->hColumns[column].len; i++) {
|
||||||
fprintf(fd, "%s%s", sep, this->hColumns[column].names[i]);
|
fprintf(fd, "%s%s", sep, this->hColumns[column].names[i]);
|
||||||
sep = " ";
|
sep = " ";
|
||||||
}
|
}
|
||||||
@ -334,7 +369,7 @@ static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned
|
|||||||
|
|
||||||
static void writeMeterModes(const Settings* this, FILE* fd, char separator, unsigned int column) {
|
static void writeMeterModes(const Settings* this, FILE* fd, char separator, unsigned int column) {
|
||||||
const char* sep = "";
|
const char* sep = "";
|
||||||
for (uint8_t i = 0; i < this->hColumns[column].len; i++) {
|
for (size_t i = 0; i < this->hColumns[column].len; i++) {
|
||||||
fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]);
|
fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]);
|
||||||
sep = " ";
|
sep = " ";
|
||||||
}
|
}
|
||||||
@ -355,9 +390,9 @@ int Settings_write(const Settings* this, bool onCrash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define printSettingInteger(setting_, value_) \
|
#define printSettingInteger(setting_, value_) \
|
||||||
fprintf(fd, setting_ "=%d%c", (int) value_, separator);
|
fprintf(fd, setting_ "=%d%c", (int) (value_), separator)
|
||||||
#define printSettingString(setting_, value_) \
|
#define printSettingString(setting_, value_) \
|
||||||
fprintf(fd, setting_ "=%s%c", value_, separator);
|
fprintf(fd, setting_ "=%s%c", value_, separator)
|
||||||
|
|
||||||
if (!onCrash) {
|
if (!onCrash) {
|
||||||
fprintf(fd, "# Beware! This file is rewritten by htop when settings are changed in the interface.\n");
|
fprintf(fd, "# Beware! This file is rewritten by htop when settings are changed in the interface.\n");
|
||||||
@ -539,7 +574,10 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns)
|
|||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
this->changed = true;
|
this->changed = true;
|
||||||
Settings_read(this, SYSCONFDIR "/htoprc", initialCpuCount);
|
ok = Settings_read(this, SYSCONFDIR "/htoprc", initialCpuCount);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
|
Settings_defaultMeters(this, initialCpuCount);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -580,7 +618,7 @@ void Settings_setHeaderLayout(Settings* this, HeaderLayout hLayout) {
|
|||||||
} else if (newColumns < oldColumns) {
|
} else if (newColumns < oldColumns) {
|
||||||
for (unsigned int i = newColumns; i < oldColumns; i++) {
|
for (unsigned int i = newColumns; i < oldColumns; i++) {
|
||||||
if (this->hColumns[i].names) {
|
if (this->hColumns[i].names) {
|
||||||
for (uint8_t j = 0; j < this->hColumns[i].len; j++)
|
for (size_t j = 0; j < this->hColumns[i].len; j++)
|
||||||
free(this->hColumns[i].names[j]);
|
free(this->hColumns[i].names[j]);
|
||||||
free(this->hColumns[i].names);
|
free(this->hColumns[i].names);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - Settings.h
|
htop - Settings.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ in the source distribution for its full text.
|
|||||||
#define CONFIG_READER_MIN_VERSION 2
|
#define CONFIG_READER_MIN_VERSION 2
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t len;
|
size_t len;
|
||||||
char** names;
|
char** names;
|
||||||
int* modes;
|
int* modes;
|
||||||
} MeterColumnSetting;
|
} MeterColumnSetting;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - SignalsPanel.c
|
htop - SignalsPanel.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - SignalsPanel.h
|
htop - SignalsPanel.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - SwapMeter.c
|
htop - SwapMeter.c
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - SwapMeter.h
|
htop - SwapMeter.h
|
||||||
(C) 2004-2011 Hisham H. Muhammad
|
(C) 2004-2011 Hisham H. Muhammad
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
htop - SysArchMeter.c
|
htop - SysArchMeter.c
|
||||||
(C) 2021 htop dev team
|
(C) 2021 htop dev team
|
||||||
Released under the GNU GPLv2, see the COPYING file
|
Released under the GNU GPLv2+, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user