version 1.62, 2007/11/06 06:56:59 |
version 1.63, 2007/11/22 11:01:04 |
|
|
/* update the header area */ |
/* update the header area */ |
i_header(header_text); |
i_header(header_text); |
|
|
|
if (topn == Infinity) { |
|
#if Default_TOPN == Infinity |
|
topn = smart_terminal ? Largest : |
|
(topn_specified ? Largest : Nominal_TOPN); |
|
#else |
|
topn = Largest; |
|
#endif |
|
} |
|
|
if (topn > 0) { |
if (topn > 0) { |
/* determine number of processes to actually display */ |
/* determine number of processes to actually display */ |
/* |
/* |
|
|
!(pfd[0].revents & (POLLERR|POLLHUP|POLLNVAL))) { |
!(pfd[0].revents & (POLLERR|POLLHUP|POLLNVAL))) { |
char *errmsg; |
char *errmsg; |
ssize_t len; |
ssize_t len; |
int newval; |
|
|
|
clear_message(); |
clear_message(); |
|
|
|
|
case CMD_number2: |
case CMD_number2: |
new_message(MT_standout, |
new_message(MT_standout, |
"Number of processes to show: "); |
"Number of processes to show: "); |
newval = readline(tempbuf, 8, Yes); |
|
if (newval > -1) { |
if (readline(tempbuf, 8) > 0) { |
if (newval > max_topn) { |
char *ptr; |
new_message(MT_standout | MT_delayed, |
ptr = tempbuf; |
" This terminal can only " |
if ((i = atoiwi(ptr)) != Invalid) { |
"display %d processes.", |
if (i > max_topn) { |
max_topn); |
new_message(MT_standout | MT_delayed, |
putr(); |
" This terminal can only " |
|
"display %d processes.", |
|
max_topn); |
|
putr(); |
|
} else if (i == 0) |
|
display_header(No); |
|
else if ((i > topn || i == -1) && topn == 0) { |
|
/* redraw the header */ |
|
display_header(Yes); |
|
} |
|
topn = i; |
|
} else { |
|
new_message(MT_standout, |
|
"Processes should be a non-negative number"); |
|
putr(); |
|
no_command = Yes; |
} |
} |
if (newval == 0) |
} else |
display_header(No); |
clear_message(); |
else if (newval > topn && topn == 0) { |
|
/* redraw the header */ |
|
display_header(Yes); |
|
} |
|
topn = newval; |
|
} |
|
break; |
break; |
|
|
case CMD_delay: /* new seconds delay */ |
case CMD_delay: /* new seconds delay */ |
new_message(MT_standout, "Seconds to delay: "); |
new_message(MT_standout, "Seconds to delay: "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
char *endp; |
char *endp; |
double newdelay = strtod(tempbuf, &endp); |
double newdelay = strtod(tempbuf, &endp); |
|
|
|
|
"Displays to show (currently %s): ", |
"Displays to show (currently %s): ", |
displays == -1 ? "infinite" : |
displays == -1 ? "infinite" : |
itoa(displays)); |
itoa(displays)); |
if ((i = readline(tempbuf, 10, Yes)) > 0) |
|
displays = i; |
|
else if (i == 0) |
|
quit(0); |
|
|
|
clear_message(); |
if (readline(tempbuf, 10) > 0) { |
|
char *ptr; |
|
ptr = tempbuf; |
|
if ((i = atoiwi(ptr)) != Invalid) { |
|
if (i == 0) |
|
quit(0); |
|
displays = i; |
|
} else { |
|
new_message(MT_standout, |
|
"Displays should be a non-negative number"); |
|
putr(); |
|
no_command = Yes; |
|
} |
|
} else |
|
clear_message(); |
break; |
break; |
|
|
case CMD_kill: /* kill program */ |
case CMD_kill: /* kill program */ |
new_message(0, "kill "); |
new_message(0, "kill "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
if ((errmsg = kill_procs(tempbuf)) != NULL) { |
if ((errmsg = kill_procs(tempbuf)) != NULL) { |
new_message(MT_standout, "%s", errmsg); |
new_message(MT_standout, "%s", errmsg); |
putr(); |
putr(); |
|
|
|
|
case CMD_renice: /* renice program */ |
case CMD_renice: /* renice program */ |
new_message(0, "renice "); |
new_message(0, "renice "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
if ((errmsg = renice_procs(tempbuf)) != NULL) { |
if ((errmsg = renice_procs(tempbuf)) != NULL) { |
new_message(MT_standout, "%s", errmsg); |
new_message(MT_standout, "%s", errmsg); |
putr(); |
putr(); |
|
|
case CMD_user: |
case CMD_user: |
new_message(MT_standout, |
new_message(MT_standout, |
"Username to show: "); |
"Username to show: "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
if (tempbuf[0] == '+' && |
if (tempbuf[0] == '+' && |
tempbuf[1] == '\0') { |
tempbuf[1] == '\0') { |
ps.uid = (uid_t)-1; |
ps.uid = (uid_t)-1; |
|
|
case CMD_order: |
case CMD_order: |
new_message(MT_standout, |
new_message(MT_standout, |
"Order to sort: "); |
"Order to sort: "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
if ((i = string_index(tempbuf, |
if ((i = string_index(tempbuf, |
statics.order_names)) == -1) { |
statics.order_names)) == -1) { |
new_message(MT_standout, |
new_message(MT_standout, |
|
|
|
|
case CMD_pid: |
case CMD_pid: |
new_message(MT_standout, "Process ID to show: "); |
new_message(MT_standout, "Process ID to show: "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
if (tempbuf[0] == '+' && |
if (tempbuf[0] == '+' && |
tempbuf[1] == '\0') { |
tempbuf[1] == '\0') { |
ps.pid = (pid_t)-1; |
ps.pid = (pid_t)-1; |
|
|
case CMD_grep: |
case CMD_grep: |
new_message(MT_standout, |
new_message(MT_standout, |
"Grep command name: "); |
"Grep command name: "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
free(ps.command); |
free(ps.command); |
if (tempbuf[0] == '+' && |
if (tempbuf[0] == '+' && |
tempbuf[1] == '\0') |
tempbuf[1] == '\0') |
|
|
|
|
case CMD_hl: |
case CMD_hl: |
new_message(MT_standout, "Process ID to highlight: "); |
new_message(MT_standout, "Process ID to highlight: "); |
if (readline(tempbuf, sizeof(tempbuf), No) > 0) { |
if (readline(tempbuf, sizeof(tempbuf)) > 0) { |
if (tempbuf[0] == '+' && |
if (tempbuf[0] == '+' && |
tempbuf[1] == '\0') { |
tempbuf[1] == '\0') { |
hlpid = -1; |
hlpid = -1; |