Merge branch 'master' of gitorious.org:procps/procps

This commit is contained in:
Craig Small 2014-05-27 20:51:25 +10:00
commit f1dc581c01
10 changed files with 407 additions and 390 deletions

4
free.1
View File

@ -32,9 +32,7 @@ kernels 2.6.32, displayed as zero if not available)
Memory used by kernel buffers (Buffers in /proc/meminfo)
.TP
\fBcached\fR
Memory used by the page cache (calculated as Cached - Shmem in
/proc/meminfo - the Cached value is actually the sum of page cache and
tmpfs memory)
Memory used by the page cache (Cached in /proc/meminfo)
.SH OPTIONS
.TP
\fB\-b\fR, \fB\-\-bytes\fR

View File

@ -682,8 +682,6 @@ nextline:
}
kb_swap_used = kb_swap_total - kb_swap_free;
kb_main_used = kb_main_total - kb_main_free;
/* "Cached" includes "Shmem" - we want only the page cache here */
kb_main_cached -= kb_main_shared;
}
/*****************************************************************/

View File

@ -1683,7 +1683,7 @@ number of kernel threads owned by the process.
T}
tid TID T{
the unique number representing a dispatacable entity (alias
the unique number representing a dispatchable entity (alias
.BR lwp , \ spid ).
This value may also appear as: a process ID (pid); a process group ID (pgrp);
a session ID for the session leader (sid); a thread group ID for the thread

View File

@ -63,8 +63,8 @@ Load in sysctl settings from the file specified or /etc/sysctl.conf if none
given. Specifying \- as filename means reading data from standard input.
Using this option will mean arguments to
.B sysctl
are files, which are read in order they are specified. The file argument can
may be specified as reqular expression.
are files, which are read in the order they are specified.
The file argument may be specified as reqular expression.
.TP
\fB\-a\fR, \fB\-\-all\fR
Display all values currently available.
@ -112,10 +112,10 @@ Alias of \fB\-p\fR
Alias of \fB\-a\fR
.TP
\fB\-o\fR
Does nothing in favour of BSD compatibility.
Does nothing, exists for BSD compatibility.
.TP
\fB\-x\fR
Does nothing in favour of BSD compatibility.
Does nothing, exists for BSD compatibility.
.TP
\fB\-h\fR, \fB\-\-help\fR
Display help text and exit.

618
top/top.1

File diff suppressed because it is too large Load Diff

126
top/top.c
View File

@ -1,6 +1,6 @@
/* top.c - Source file: show Linux processes */
/*
* Copyright (c) 2002-2013, by: James C. Warner
* Copyright (c) 2002-2014, by: James C. Warner
* All rights reserved. 8921 Hilloway Road
* Eden Prairie, Minnesota 55347 USA
*
@ -1150,8 +1150,11 @@ static char *ioline (const char *prompt) {
key = iokey(2);
switch (key) {
case 0:
buf[0] = '\0';
return buf;
case kbd_ESC:
buf[0] = '\0'; // fall through !
buf[0] = kbd_ESC;
return buf;
case kbd_ENTER:
continue;
case kbd_INS:
@ -1180,13 +1183,13 @@ static char *ioline (const char *prompt) {
if (plin->bkw) {
plin = plin->bkw;
memset(buf, '\0', sizeof(buf));
pos = snprintf(buf, sizeof(buf), "%s", plin->str);
pos = snprintf(buf, sizeof(buf), "%.*s", Screen_cols - beg - 1, plin->str);
}
break;
case kbd_DOWN:
memset(buf, '\0', sizeof(buf));
if (plin->fwd) plin = plin->fwd;
pos = snprintf(buf, sizeof(buf), "%s", plin->str);
pos = snprintf(buf, sizeof(buf), "%.*s", Screen_cols - beg - 1, plin->str);
break;
default: // what we REALLY wanted (maybe)
if (isprint(key) && logCOL < bufMAX && phyCOL < Screen_cols) {
@ -1197,7 +1200,7 @@ static char *ioline (const char *prompt) {
}
putp(fmtmk("%s%s%s", tg2(beg, Msg_row), Cap_clr_eol, buf));
putp(tg2(beg+pos, Msg_row));
} while (key && key != kbd_ENTER && key != kbd_ESC);
} while (key != kbd_ENTER);
// weed out duplicates, including empty strings (top-of-stack)...
for (i = 0, plin = anchor; ; i++) {
@ -1275,6 +1278,10 @@ static int readfile (FILE *fp, char **baddr, size_t *bsize, size_t *bread) {
/*###### Small Utility routines ########################################*/
#define GET_NUM_BAD INT_MIN
#define GET_NUM_ESC (INT_MIN + 1)
#define GET_NUM_NOT (INT_MIN + 2)
/*
* Get a float from the user */
static float get_float (const char *prompt) {
@ -1282,20 +1289,18 @@ static float get_float (const char *prompt) {
float f;
line = ioline(prompt);
if (!line[0] || Frames_signal) return -1.0;
if (line[0] == kbd_ESC || Frames_signal) return GET_NUM_ESC;
if (!line[0]) return GET_NUM_NOT;
// note: we're not allowing negative floats
if (strcspn(line, "+,.0123456789")) {
show_msg(N_txt(BAD_numfloat_txt));
return -1.0;
return GET_NUM_BAD;
}
sscanf(line, "%f", &f);
return f;
} // end: get_float
#define GET_INT_BAD INT_MIN
#define GET_INTNONE (INT_MIN + 1)
/*
* Get an integer from the user, returning INT_MIN for error */
static int get_int (const char *prompt) {
@ -1303,12 +1308,12 @@ static int get_int (const char *prompt) {
int n;
line = ioline(prompt);
if (Frames_signal) return GET_INT_BAD;
if (!line[0]) return GET_INTNONE;
if (line[0] == kbd_ESC || Frames_signal) return GET_NUM_ESC;
if (!line[0]) return GET_NUM_NOT;
// note: we've got to allow negative ints (renice)
if (strcspn(line, "-+0123456789")) {
show_msg(N_txt(BAD_integers_txt));
return GET_INT_BAD;
return GET_NUM_BAD;
}
sscanf(line, "%d", &n);
return n;
@ -2518,17 +2523,15 @@ static void procs_hlp (proc_t *this) {
HST_t *h;
if (!this) {
static struct timeval oldtimev;
struct timeval timev;
struct timezone timez;
static double uptime_sav;
double uptime_cur;
float et;
void *v;
gettimeofday(&timev, &timez);
et = (timev.tv_sec - oldtimev.tv_sec)
+ (float)(timev.tv_usec - oldtimev.tv_usec) / 1000000.0;
oldtimev.tv_sec = timev.tv_sec;
oldtimev.tv_usec = timev.tv_usec;
uptime(&uptime_cur, NULL);
et = uptime_cur - uptime_sav;
if (et < 0.01) et = 0.005;
uptime_sav = uptime_cur;
// if in Solaris mode, adjust our scaling for all cpus
Frame_etscale = 100.0f / ((float)Hertz * (float)et * (Rc.mode_irixps ? 1 : smp_num_cpus));
@ -2920,7 +2923,9 @@ static void insp_find_str (int ch, int *col, int *row) {
return;
}
if (ch == 'L' || ch == '/') {
snprintf(Insp_sel->fstr, FNDBUFSIZ, "%s", ioline(N_txt(GET_find_str_txt)));
char *str = ioline(N_txt(GET_find_str_txt));
if (*str == kbd_ESC) return;
snprintf(Insp_sel->fstr, FNDBUFSIZ, "%s", str);
Insp_sel->flen = strlen(Insp_sel->fstr);
found = 0;
}
@ -3467,7 +3472,7 @@ static void configs_read (void) {
if (2 != fscanf(fp, "%3s\tfieldscur=%79s\n"
, w->rc.winname, w->rc.fieldscur))
goto default_or_error;
#if PFLAGSSIZ > 80
#if PFLAGSSIZ != 80
// too bad fscanf is not as flexible with his format string as snprintf
# error Hey, fix the above fscanf 'PFLAGSSIZ' dependency !
#endif
@ -4137,7 +4142,9 @@ static void find_string (int ch) {
return;
}
if ('L' == ch) {
snprintf(Curwin->findstr, FNDBUFSIZ, "%s", ioline(N_txt(GET_find_str_txt)));
char *str = ioline(N_txt(GET_find_str_txt));
if (*str == kbd_ESC) return;
snprintf(Curwin->findstr, FNDBUFSIZ, "%s", str);
Curwin->findlen = strlen(Curwin->findstr);
found = 0;
#ifndef USE_X_COLHDR
@ -4227,7 +4234,9 @@ static void other_selection (int ch) {
sel = strstr;
}
glob = ioline(fmtmk(N_fmt(OSEL_prompts_fmt), Curwin->osel_tot + 1, typ));
if (!snprintf(raw, sizeof(raw), "%s", glob)) return;
if (*glob == kbd_ESC
|| !snprintf(raw, sizeof(raw), "%s", glob))
return;
for (osel = Curwin->osel_1st; osel; ) {
if (!strcmp(osel->raw, glob)) { // #1: is criteria duplicate?
show_msg(N_txt(OSEL_errdups_txt));
@ -4345,7 +4354,7 @@ static void keys_global (int ch) {
else {
float tmp =
get_float(fmtmk(N_fmt(DELAY_change_fmt), Rc.delay_time));
if (-1 < tmp) Rc.delay_time = tmp;
if (tmp > -1) Rc.delay_time = tmp;
}
break;
case 'E':
@ -4381,17 +4390,21 @@ static void keys_global (int ch) {
if (Secure_mode) {
show_msg(N_txt(NOT_onsecure_txt));
} else {
int pid, sig = SIGTERM, def = w->ppt[w->begtask]->tid;
if (GET_INT_BAD < (pid = get_int(fmtmk(N_txt(GET_pid2kill_fmt), def)))) {
int sig = SIGTERM,
def = w->ppt[w->begtask]->tid,
pid = get_int(fmtmk(N_txt(GET_pid2kill_fmt), def));
if (pid > GET_NUM_ESC) {
char *str;
if (0 > pid) pid = def;
if (pid == GET_NUM_NOT) pid = def;
str = ioline(fmtmk(N_fmt(GET_sigs_num_fmt), pid, SIGTERM));
if (*str) sig = signal_name_to_number(str);
if (Frames_signal) break;
if (0 < sig && kill(pid, sig))
show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
, pid, sig, strerror(errno)));
else if (0 > sig) show_msg(N_txt(BAD_signalid_txt));
if (*str != kbd_ESC) {
if (*str) sig = signal_name_to_number(str);
if (Frames_signal) break;
if (0 < sig && kill(pid, sig))
show_msg(fmtmk(N_fmt(FAIL_signals_fmt)
, pid, sig, strerror(errno)));
else if (0 > sig) show_msg(N_txt(BAD_signalid_txt));
}
}
}
break;
@ -4399,21 +4412,24 @@ static void keys_global (int ch) {
if (Secure_mode)
show_msg(N_txt(NOT_onsecure_txt));
else {
int val, pid, def = w->ppt[w->begtask]->tid;
if (GET_INT_BAD < (pid = get_int(fmtmk(N_txt(GET_pid2nice_fmt), def)))) {
if (0 > pid) pid = def;
if (GET_INTNONE < (val = get_int(fmtmk(N_fmt(GET_nice_num_fmt), pid))))
if (setpriority(PRIO_PROCESS, (unsigned)pid, val))
show_msg(fmtmk(N_fmt(FAIL_re_nice_fmt)
, pid, val, strerror(errno)));
int val,
def = w->ppt[w->begtask]->tid,
pid = get_int(fmtmk(N_txt(GET_pid2nice_fmt), def));
if (pid > GET_NUM_ESC) {
if (pid == GET_NUM_NOT) pid = def;
val = get_int(fmtmk(N_fmt(GET_nice_num_fmt), pid));
if (val > GET_NUM_NOT
&& setpriority(PRIO_PROCESS, (unsigned)pid, val))
show_msg(fmtmk(N_fmt(FAIL_re_nice_fmt)
, pid, val, strerror(errno)));
}
}
break;
case 'X':
{ int wide = get_int(fmtmk(N_fmt(XTRA_fixwide_fmt), Rc.fixed_widest));
if (GET_INTNONE < wide) {
if (-1 < wide) Rc.fixed_widest = wide;
else if (INT_MIN < wide) Rc.fixed_widest = -1;
if (wide > GET_NUM_NOT) {
if (wide > -1) Rc.fixed_widest = wide;
else Rc.fixed_widest = -1;
}
}
break;
@ -4421,9 +4437,10 @@ static void keys_global (int ch) {
if (!Inspect.total)
ioline(N_txt(YINSP_noents_txt));
else {
int pid, def = w->ppt[w->begtask]->tid;
if (GET_INT_BAD < (pid = get_int(fmtmk(N_fmt(YINSP_pidsee_fmt), def)))) {
if (0 > pid) pid = def;
int def = w->ppt[w->begtask]->tid,
pid = get_int(fmtmk(N_fmt(YINSP_pidsee_fmt), def));
if (pid > GET_NUM_ESC) {
if (pid == GET_NUM_NOT) pid = def;
if (pid) inspection_utility(pid);
}
}
@ -4469,7 +4486,7 @@ static void keys_summary (int ch) {
show_msg(N_txt(NUMA_nodenot_txt));
else {
int num = get_int(fmtmk(N_fmt(NUMA_nodeget_fmt), Numa_node_tot -1));
if (GET_INTNONE < num) {
if (num > GET_NUM_NOT) {
if (num >= 0 && num < Numa_node_tot) {
Numa_node_sel = num;
SETw(w, View_CPUNOD | View_STATES);
@ -4505,7 +4522,7 @@ static void keys_task (int ch) {
case 'n':
if (VIZCHKw(w)) {
int num = get_int(fmtmk(N_fmt(GET_max_task_fmt), w->rc.maxtasks));
if (GET_INTNONE < num) {
if (num > GET_NUM_NOT) {
if (-1 < num ) w->rc.maxtasks = num;
else show_msg(N_txt(BAD_max_task_txt));
}
@ -4603,9 +4620,10 @@ static void keys_task (int ch) {
case 'U':
case 'u':
if (VIZCHKw(w)) {
const char *errmsg;
if ((errmsg = user_certify(w, ioline(N_txt(GET_user_ids_txt)), ch)))
show_msg(errmsg);
const char *errmsg, *str = ioline(N_txt(GET_user_ids_txt));
if (*str != kbd_ESC
&& (errmsg = user_certify(w, str, ch)))
show_msg(errmsg);
}
break;
case 'V':
@ -4688,7 +4706,7 @@ static void keys_window (int ch) {
if (ALTCHKw) {
char tmp[SMLBUFSIZ];
STRLCPY(tmp, ioline(fmtmk(N_fmt(NAME_windows_fmt), w->rc.winname)));
if (tmp[0]) win_names(w, tmp);
if (tmp[0] && tmp[0] != kbd_ESC) win_names(w, tmp);
}
break;
case kbd_UP:

View File

@ -1,6 +1,6 @@
/* top.h - Header file: show Linux processes */
/*
* Copyright (c) 2002-2013, by: James C. Warner
* Copyright (c) 2002-2014, by: James C. Warner
* All rights reserved. 8921 Hilloway Road
* Eden Prairie, Minnesota 55347 USA
*

View File

@ -1,6 +1,6 @@
/* top_nls.c - provide the basis for future nls translations */
/*
* Copyright (c) 2011-2013, by: James C. Warner
* Copyright (c) 2011-2014, by: James C. Warner
* All rights reserved. 8921 Hilloway Road
* Eden Prairie, Minnesota 55347 USA
*
@ -129,31 +129,31 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'UID' = 5 */
Head_nlstab[EU_UED] = _("UID");
Desc_nlstab[EU_UED] = _("Effective User Id");
/* Translation Hint: maximum 'USER' = 8 */
/* Translation Hint: maximum 'USER' = 7 */
Head_nlstab[EU_UEN] = _("USER");
Desc_nlstab[EU_UEN] = _("Effective User Name");
/* Translation Hint: maximum 'RUID' = 5 */
Head_nlstab[EU_URD] = _("RUID");
Desc_nlstab[EU_URD] = _("Real User Id");
/* Translation Hint: maximum 'RUSER' = 8 */
/* Translation Hint: maximum 'RUSER' = 7 */
Head_nlstab[EU_URN] = _("RUSER");
Desc_nlstab[EU_URN] = _("Real User Name");
/* Translation Hint: maximum 'SUID' = 5 */
Head_nlstab[EU_USD] = _("SUID");
Desc_nlstab[EU_USD] = _("Saved User Id");
/* Translation Hint: maximum 'SUSER' = 8 */
/* Translation Hint: maximum 'SUSER' = 7 */
Head_nlstab[EU_USN] = _("SUSER");
Desc_nlstab[EU_USN] = _("Saved User Name");
/* Translation Hint: maximum 'GID' = 5 */
Head_nlstab[EU_GID] = _("GID");
Desc_nlstab[EU_GID] = _("Group Id");
/* Translation Hint: maximum 'GROUP' = 8 */
/* Translation Hint: maximum 'GROUP' = 7 */
Head_nlstab[EU_GRP] = _("GROUP");
Desc_nlstab[EU_GRP] = _("Group Name");
/* Translation Hint: maximum 'PGRP' = 5 */
Head_nlstab[EU_PGD] = _("PGRP");
Desc_nlstab[EU_PGD] = _("Process Group Id");
/* Translation Hint: maximum 'TTY' = 8 */
/* Translation Hint: maximum 'TTY' = 7 */
Head_nlstab[EU_TTY] = _("TTY");
Desc_nlstab[EU_TTY] = _("Controlling Tty");
/* Translation Hint: maximum 'TPGID' = 5 */
@ -180,7 +180,7 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum '' = 6 */
Head_nlstab[EU_TME] = _("TIME");
Desc_nlstab[EU_TME] = _("CPU Time");
/* Translation Hint: maximum 'TIME+' = 9 */
/* Translation Hint: maximum 'TIME+' = 7 */
Head_nlstab[EU_TM2] = _("TIME+");
Desc_nlstab[EU_TM2] = _("CPU Time, hundredths");
/* Translation Hint: maximum '%MEM' = 4 */
@ -222,7 +222,7 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'WCHAN' = 7 */
Head_nlstab[EU_WCH] = _("WCHAN");
Desc_nlstab[EU_WCH] = _("Sleeping in Function");
/* Translation Hint: maximum 'Flags' = 8 */
/* Translation Hint: maximum 'Flags' = 7 */
Head_nlstab[EU_FLG] = _("Flags");
Desc_nlstab[EU_FLG] = _("Task Flags <sched.h>");
/* Translation Hint: maximum 'CGROUPS' = 7 */
@ -241,7 +241,7 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'Adj' = 3 */
Head_nlstab[EU_OOA] = _("Adj");
Desc_nlstab[EU_OOA] = _("oom_adjustment (2^X)");
/* Translation Hint: maximum 'Badness' = 8 */
/* Translation Hint: maximum 'Badness' = 7 */
Head_nlstab[EU_OOM] = _("Badness");
Desc_nlstab[EU_OOM] = _("oom_score (badness)");
#endif
@ -259,22 +259,22 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'USED' = 4 */
Head_nlstab[EU_USE] = _("USED");
Desc_nlstab[EU_USE] = _("Res+Swap Size (KiB)");
/* Translation Hint: maximum 'nsIPC' = 10 */
/* Translation Hint: maximum 'nsIPC' = 7 */
Head_nlstab[EU_NS1] = _("nsIPC");
Desc_nlstab[EU_NS1] = _("IPC namespace Inode");
/* Translation Hint: maximum 'nsMNT' = 10 */
/* Translation Hint: maximum 'nsMNT' = 7 */
Head_nlstab[EU_NS2] = _("nsMNT");
Desc_nlstab[EU_NS2] = _("MNT namespace Inode");
/* Translation Hint: maximum 'nsNET' = 10 */
/* Translation Hint: maximum 'nsNET' = 7 */
Head_nlstab[EU_NS3] = _("nsNET");
Desc_nlstab[EU_NS3] = _("NET namespace Inode");
/* Translation Hint: maximum 'nsPID' = 10 */
/* Translation Hint: maximum 'nsPID' = 7 */
Head_nlstab[EU_NS4] = _("nsPID");
Desc_nlstab[EU_NS4] = _("PID namespace Inode");
/* Translation Hint: maximum 'nsUSER' = 10 */
/* Translation Hint: maximum 'nsUSER' = 7 */
Head_nlstab[EU_NS5] = _("nsUSER");
Desc_nlstab[EU_NS5] = _("USER namespace Inode");
/* Translation Hint: maximum 'nsUTS' = 10 */
/* Translation Hint: maximum 'nsUTS' = 7 */
Head_nlstab[EU_NS6] = _("nsUTS");
Desc_nlstab[EU_NS6] = _("UTS namespace Inode");
}

View File

@ -1,6 +1,6 @@
/* top_nls.h - provide the basis for future nls translations */
/*
* Copyright (c) 2011-2013, by: James C. Warner
* Copyright (c) 2011-2014, by: James C. Warner
* All rights reserved. 8921 Hilloway Road
* Eden Prairie, Minnesota 55347 USA
*

View File

@ -102,8 +102,7 @@ b: The number of processes in uninterruptible sleep.
swpd: the amount of virtual memory used.
free: the amount of idle memory.
buff: the amount of memory used as buffers.
cache: the amount of memory used as cache (excluding tmpfs memory for
kernels 2.6.32+)
cache: the amount of memory used as cache.
inact: the amount of inactive memory. (\-a option)
active: the amount of active memory. (\-a option)
.fi