aboutsummaryrefslogtreecommitdiffstats
path: root/htop.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:00:20 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:00:20 +0200
commitea859f50d9438bc61ae96721a4d255b49de78653 (patch)
treebfb52a5f403ad1e86c562b2f4d608d1268fe8fcf /htop.c
parent266ab52b3a741a58fb17c48b0f7939d7c5d266de (diff)
downloaddebian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.tar.gz
debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.tar.bz2
debian_htop-ea859f50d9438bc61ae96721a4d255b49de78653.zip
Imported Upstream version 0.6.2upstream/0.6.2
Diffstat (limited to 'htop.c')
-rw-r--r--htop.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/htop.c b/htop.c
index a1bd7ee..4290920 100644
--- a/htop.c
+++ b/htop.c
@@ -1,6 +1,6 @@
/*
htop - htop.c
-(C) 2004,2005 Hisham H. Muhammad
+(C) 2004-2006 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
in the source distribution for its full text.
*/
@@ -38,14 +38,14 @@ char htop_barCharacters[] = "|#*@$%&";
void printVersionFlag() {
clear();
- printf("htop " VERSION " - (C) 2004,2005 Hisham Muhammad.\n");
+ printf("htop " VERSION " - (C) 2004-2006 Hisham Muhammad.\n");
printf("Released under the GNU GPL.\n\n");
exit(0);
}
void printHelpFlag() {
clear();
- printf("htop " VERSION " - (C) 2004,2005 Hisham Muhammad.\n");
+ printf("htop " VERSION " - (C) 2004-2006 Hisham Muhammad.\n");
printf("Released under the GNU GPL.\n\n");
printf("-d DELAY Delay between updates, in tenths of seconds\n\n");
printf("-u USERNAME Show only processes of a given user\n\n");
@@ -57,7 +57,7 @@ void printHelpFlag() {
void showHelp() {
clear();
attrset(CRT_colors[HELP_BOLD]);
- mvaddstr(0, 0, "htop " VERSION " - (C) 2004 Hisham Muhammad.");
+ mvaddstr(0, 0, "htop " VERSION " - (C) 2004-2006 Hisham Muhammad.");
mvaddstr(1, 0, "Released under the GNU GPL. See 'man' page for more info.");
attrset(CRT_colors[DEFAULT_COLOR]);
@@ -213,6 +213,11 @@ int main(int argc, char** argv) {
setUserOnly(argv[2], &userOnly, &userId);
}
}
+
+ if (access(PROCDIR, R_OK) != 0) {
+ fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
+ exit(1);
+ }
ListBox* lb;
int quit = 0;
@@ -268,6 +273,8 @@ int main(int argc, char** argv) {
double oldTime = 0.0;
bool recalculate;
+ int ch = 0;
+ int closeTimeout = 0;
while (!quit) {
gettimeofday(&tv, NULL);
@@ -309,12 +316,24 @@ int main(int argc, char** argv) {
Header_draw(header);
ListBox_draw(lb, true);
- int ch = getch();
+ int prev = ch;
+ ch = getch();
+
+ if (ch == ERR) {
+ if (!incSearchMode)
+ refreshTimeout--;
+ if (prev == ch && !recalculate) {
+ closeTimeout++;
+ if (closeTimeout == 10)
+ break;
+ } else
+ closeTimeout = 0;
+ continue;
+ }
+
if (incSearchMode) {
doRefresh = false;
- if (ch == ERR) {
- continue;
- } else if (ch == KEY_F(3)) {
+ if (ch == KEY_F(3)) {
int here = ListBox_getSelectedIndex(lb);
int size = ProcessList_size(pl);
int i = here+1;
@@ -393,9 +412,6 @@ int main(int argc, char** argv) {
}
switch (ch) {
- case ERR:
- refreshTimeout--;
- continue;
case KEY_RESIZE:
ListBox_resize(lb, COLS, LINES-headerHeight-1);
if (incSearchMode)

© 2014-2024 Faster IT GmbH | imprint | privacy policy