ps: built-in test code, etc.
This commit is contained in:
parent
630b655893
commit
6ec1cff342
4
Makefile
4
Makefile
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
VERSION := 3
|
VERSION := 3
|
||||||
SUBVERSION := 2
|
SUBVERSION := 2
|
||||||
MINORVERSION := 3
|
MINORVERSION := 4
|
||||||
TARVERSION := $(VERSION).$(SUBVERSION).$(MINORVERSION)
|
TARVERSION := $(VERSION).$(SUBVERSION).$(MINORVERSION)
|
||||||
|
|
||||||
############ vars
|
############ vars
|
||||||
@ -121,7 +121,7 @@ ALL_CFLAGS += $(m64)
|
|||||||
|
|
||||||
ALL_CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
|
ALL_CFLAGS += $(call check_gcc,-Wdeclaration-after-statement,)
|
||||||
ALL_CFLAGS += $(call check_gcc,-Wpadded,)
|
ALL_CFLAGS += $(call check_gcc,-Wpadded,)
|
||||||
ALL_CFLAGS += $(call check_gcc,-Wstrict-aliasing=2,)
|
ALL_CFLAGS += $(call check_gcc,-Wstrict-aliasing,)
|
||||||
|
|
||||||
# Adding -fno-gcse might be good for those files which
|
# Adding -fno-gcse might be good for those files which
|
||||||
# use computed goto.
|
# use computed goto.
|
||||||
|
@ -14,9 +14,6 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
extern int escape_strlist(char *restrict dst, const char *restrict const *restrict src, size_t n);
|
extern int escape_strlist(char *restrict dst, const char *restrict const *restrict src, size_t n);
|
||||||
extern int escape_str(char *restrict dst, const char *restrict src, int bufsize, int maxglyphs);
|
extern int escape_str(char *restrict dst, const char *restrict src, int bufsize, int maxglyphs);
|
||||||
extern int octal_escape_str(char *restrict dst, const char *restrict src, size_t n);
|
|
||||||
extern int simple_escape_str(char *restrict dst, const char *restrict src, size_t n);
|
|
||||||
|
|
||||||
extern int escape_command(char *restrict const outbuf, const proc_t *restrict const pp, int bytes, int glyphs, unsigned flags);
|
extern int escape_command(char *restrict const outbuf, const proc_t *restrict const pp, int bytes, int glyphs, unsigned flags);
|
||||||
|
|
||||||
EXTERN_C_END
|
EXTERN_C_END
|
||||||
|
@ -204,7 +204,7 @@ static void init_libproc(void){
|
|||||||
if(linux_version_code > LINUX_VERSION(2, 4, 0)){
|
if(linux_version_code > LINUX_VERSION(2, 4, 0)){
|
||||||
Hertz = find_elf_note(AT_CLKTCK);
|
Hertz = find_elf_note(AT_CLKTCK);
|
||||||
if(Hertz!=NOTE_NOT_FOUND) return;
|
if(Hertz!=NOTE_NOT_FOUND) return;
|
||||||
fprintf(stderr, "2.4 kernel w/o ELF notes? -- report this\n");
|
fprintf(stderr, "2.4+ kernel w/o ELF notes? -- report this\n");
|
||||||
}
|
}
|
||||||
old_Hertz_hack();
|
old_Hertz_hack();
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
Begin4
|
Begin4
|
||||||
Title: procps
|
Title: procps
|
||||||
Version: 3.2.2
|
Version: 3.2.4
|
||||||
Entered-date: 2004-7-15
|
Entered-date: 2004-9-23
|
||||||
Description: Linux system utilities
|
Description: Linux system utilities
|
||||||
Keywords: procps /proc libproc sysctl pmap ps uptime tload slabtop
|
Keywords: procps /proc libproc sysctl pmap ps uptime tload slabtop
|
||||||
free w top vmstat watch skill snice kill pgrep pkill
|
free w top vmstat watch skill snice kill pgrep pkill
|
||||||
Author: Albert Cahalan, Michael K. Johnson, Jim Warner, etc.
|
Author: Albert Cahalan, Michael K. Johnson, Jim Warner, etc.
|
||||||
Maintained-by: various <procps-feedback@lists.sf.net>
|
Maintained-by: various <procps-feedback@lists.sf.net>
|
||||||
Primary-site: http://procps.sf.net/
|
Primary-site: http://procps.sf.net/
|
||||||
261kB procps-3.2.2.tar.gz
|
261kB procps-3.2.4.tar.gz
|
||||||
Alternate-site: http://www.debian.org/Packages/unstable/base/procps.html
|
Alternate-site: http://www.debian.org/Packages/unstable/base/procps.html
|
||||||
261kB procps-3.2.2.tar.gz
|
261kB procps-3.2.4.tar.gz
|
||||||
Copying-policy: mixed
|
Copying-policy: mixed
|
||||||
End
|
End
|
||||||
|
@ -3,7 +3,7 @@ Summary: System and process monitoring utilities
|
|||||||
Name: procps
|
Name: procps
|
||||||
%define major_version 3
|
%define major_version 3
|
||||||
%define minor_version 2
|
%define minor_version 2
|
||||||
%define revision 3
|
%define revision 4
|
||||||
%define version %{major_version}.%{minor_version}.%{revision}
|
%define version %{major_version}.%{minor_version}.%{revision}
|
||||||
Version: %{version}
|
Version: %{version}
|
||||||
Release: 1
|
Release: 1
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
#define HPU 8 /* HP-UX */
|
#define HPU 8 /* HP-UX */
|
||||||
#define SGI 9 /* Irix */
|
#define SGI 9 /* Irix */
|
||||||
#define SOE 10 /* IBM's S/390 OpenEdition */
|
#define SOE 10 /* IBM's S/390 OpenEdition */
|
||||||
|
#define TST 11 /* test code */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try not to overflow the output buffer:
|
* Try not to overflow the output buffer:
|
||||||
|
67
ps/output.c
67
ps/output.c
@ -610,7 +610,7 @@ static int pr_wchan(char *restrict const outbuf, const proc_t *restrict const pp
|
|||||||
* only one thread waiting in the kernel, and '*' when there is
|
* only one thread waiting in the kernel, and '*' when there is
|
||||||
* more than one thread waiting in the kernel.
|
* more than one thread waiting in the kernel.
|
||||||
*/
|
*/
|
||||||
if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "%s", "-");
|
if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "-");
|
||||||
if(wchan_is_number) return snprintf(outbuf, COLWID, "%x", (unsigned)(pp->wchan) & 0xffffffu);
|
if(wchan_is_number) return snprintf(outbuf, COLWID, "%x", (unsigned)(pp->wchan) & 0xffffffu);
|
||||||
return snprintf(outbuf, COLWID, "%s", lookup_wchan(pp->wchan, pp->XXXID));
|
return snprintf(outbuf, COLWID, "%s", lookup_wchan(pp->wchan, pp->XXXID));
|
||||||
}
|
}
|
||||||
@ -804,7 +804,12 @@ static int pr_majflt(char *restrict const outbuf, const proc_t *restrict const p
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int pr_lim(char *restrict const outbuf, const proc_t *restrict const pp){
|
static int pr_lim(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
if(pp->rss_rlim == RLIM_INFINITY) return snprintf(outbuf, COLWID, "%s", "xx");
|
if(pp->rss_rlim == RLIM_INFINITY){
|
||||||
|
outbuf[0] = 'x';
|
||||||
|
outbuf[1] = 'x';
|
||||||
|
outbuf[2] = '\0';
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
return snprintf(outbuf, COLWID, "%5ld", pp->rss_rlim >> 10);
|
return snprintf(outbuf, COLWID, "%5ld", pp->rss_rlim >> 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -820,7 +825,7 @@ static int pr_wname(char *restrict const outbuf, const proc_t *restrict const pp
|
|||||||
* only one thread waiting in the kernel, and '*' when there is
|
* only one thread waiting in the kernel, and '*' when there is
|
||||||
* more than one thread waiting in the kernel.
|
* more than one thread waiting in the kernel.
|
||||||
*/
|
*/
|
||||||
if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "%s", "-");
|
if(!(pp->wchan & 0xffffff)) return snprintf(outbuf, COLWID, "-");
|
||||||
return snprintf(outbuf, COLWID, "%s", lookup_wchan(pp->wchan, pp->XXXID));
|
return snprintf(outbuf, COLWID, "%s", lookup_wchan(pp->wchan, pp->XXXID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1059,6 +1064,44 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////// Test code /////////////////////////////////
|
||||||
|
|
||||||
|
// like "args"
|
||||||
|
static int pr_t_unlimited(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
static const char *const vals[] = {"[123456789-12345] <defunct>","ps","123456789-123456"};
|
||||||
|
(void)pp;
|
||||||
|
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%3u]);
|
||||||
|
}
|
||||||
|
static int pr_t_unlimited2(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
static const char *const vals[] = {"unlimited", "[123456789-12345] <defunct>","ps","123456789-123456"};
|
||||||
|
(void)pp;
|
||||||
|
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%4u]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// like "etime"
|
||||||
|
static int pr_t_right(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
static const char *const vals[] = {"999-23:59:59","99-23:59:59","9-23:59:59","59:59"};
|
||||||
|
(void)pp;
|
||||||
|
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%4u]);
|
||||||
|
}
|
||||||
|
static int pr_t_right2(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
static const char *const vals[] = {"999-23:59:59","99-23:59:59","9-23:59:59"};
|
||||||
|
(void)pp;
|
||||||
|
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%3u]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// like "tty"
|
||||||
|
static int pr_t_left(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
static const char *const vals[] = {"tty7","pts/9999","iseries/vtty42","ttySMX0","3270/tty4"};
|
||||||
|
(void)pp;
|
||||||
|
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%5u]);
|
||||||
|
}
|
||||||
|
static int pr_t_left2(char *restrict const outbuf, const proc_t *restrict const pp){
|
||||||
|
static const char *const vals[] = {"tty7","pts/9999","ttySMX0","3270/tty4"};
|
||||||
|
(void)pp;
|
||||||
|
return snprintf(outbuf, COLWID, "%s", vals[lines_to_next_header%4u]);
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************/
|
/***************************************************************************/
|
||||||
/*************************** other stuff ***********************************/
|
/*************************** other stuff ***********************************/
|
||||||
|
|
||||||
@ -1123,13 +1166,19 @@ static const format_struct format_array[] = {
|
|||||||
/* code header print() sort() width need vendor flags */
|
/* code header print() sort() width need vendor flags */
|
||||||
{"%cpu", "%CPU", pr_pcpu, sr_pcpu, 4, 0, BSD, ET|RIGHT}, /*pcpu*/
|
{"%cpu", "%CPU", pr_pcpu, sr_pcpu, 4, 0, BSD, ET|RIGHT}, /*pcpu*/
|
||||||
{"%mem", "%MEM", pr_pmem, sr_nop, 4, 0, BSD, PO|RIGHT}, /*pmem*/
|
{"%mem", "%MEM", pr_pmem, sr_nop, 4, 0, BSD, PO|RIGHT}, /*pmem*/
|
||||||
|
{"_left", "LLLLLLLL", pr_t_left, sr_nop, 8, 0, TST, ET|LEFT},
|
||||||
|
{"_left2", "L2L2L2L2", pr_t_left2, sr_nop, 8, 0, TST, ET|LEFT},
|
||||||
|
{"_right", "RRRRRRRRRRR", pr_t_right, sr_nop, 11, 0, TST, ET|RIGHT},
|
||||||
|
{"_right2", "R2R2R2R2R2R", pr_t_right2, sr_nop, 11, 0, TST, ET|RIGHT},
|
||||||
|
{"_unlimited","U", pr_t_unlimited, sr_nop, 16, 0, TST, ET|UNLIMITED},
|
||||||
|
{"_unlimited2","U2", pr_t_unlimited2, sr_nop, 16, 0, TST, ET|UNLIMITED},
|
||||||
{"acflag", "ACFLG", pr_nop, sr_nop, 5, 0, XXX, AN|RIGHT}, /*acflg*/
|
{"acflag", "ACFLG", pr_nop, sr_nop, 5, 0, XXX, AN|RIGHT}, /*acflg*/
|
||||||
{"acflg", "ACFLG", pr_nop, sr_nop, 5, 0, BSD, AN|RIGHT}, /*acflag*/
|
{"acflg", "ACFLG", pr_nop, sr_nop, 5, 0, BSD, AN|RIGHT}, /*acflag*/
|
||||||
{"addr", "ADDR", pr_nop, sr_nop, 4, 0, XXX, AN|RIGHT},
|
{"addr", "ADDR", pr_nop, sr_nop, 4, 0, XXX, AN|RIGHT},
|
||||||
{"addr_1", "ADDR", pr_nop, sr_nop, 1, 0, LNX, AN|LEFT},
|
{"addr_1", "ADDR", pr_nop, sr_nop, 1, 0, LNX, AN|LEFT},
|
||||||
{"alarm", "ALARM", pr_alarm, sr_alarm, 5, 0, LNX, AN|RIGHT},
|
{"alarm", "ALARM", pr_alarm, sr_alarm, 5, 0, LNX, AN|RIGHT},
|
||||||
{"argc", "ARGC", pr_nop, sr_nop, 4, 0, LNX, PO|RIGHT},
|
{"argc", "ARGC", pr_nop, sr_nop, 4, 0, LNX, PO|RIGHT},
|
||||||
{"args", "COMMAND", pr_args, sr_cmd, 16, ARG, U98, PO|UNLIMITED}, /*command*/
|
{"args", "COMMAND", pr_args, sr_cmd, 27, ARG, U98, PO|UNLIMITED}, /*command*/
|
||||||
{"atime", "TIME", pr_time, sr_nop, 8, 0, SOE, ET|RIGHT}, /*cputime*/ /* was 6 wide */
|
{"atime", "TIME", pr_time, sr_nop, 8, 0, SOE, ET|RIGHT}, /*cputime*/ /* was 6 wide */
|
||||||
{"blocked", "BLOCKED", pr_sigmask, sr_nop, 9, 0, BSD, TO|SIGNAL}, /*sigmask*/
|
{"blocked", "BLOCKED", pr_sigmask, sr_nop, 9, 0, BSD, TO|SIGNAL}, /*sigmask*/
|
||||||
{"bnd", "BND", pr_nop, sr_nop, 1, 0, AIX, TO|RIGHT},
|
{"bnd", "BND", pr_nop, sr_nop, 1, 0, AIX, TO|RIGHT},
|
||||||
@ -1140,11 +1189,11 @@ static const format_struct format_array[] = {
|
|||||||
{"class", "CLS", pr_class, sr_sched, 3, 0, XXX, TO|LEFT},
|
{"class", "CLS", pr_class, sr_sched, 3, 0, XXX, TO|LEFT},
|
||||||
{"cls", "CLS", pr_class, sr_sched, 3, 0, HPU, TO|RIGHT}, /*says HPUX or RT*/
|
{"cls", "CLS", pr_class, sr_sched, 3, 0, HPU, TO|RIGHT}, /*says HPUX or RT*/
|
||||||
{"cmaj_flt", "-", pr_nop, sr_cmaj_flt, 1, 0, LNX, AN|RIGHT},
|
{"cmaj_flt", "-", pr_nop, sr_cmaj_flt, 1, 0, LNX, AN|RIGHT},
|
||||||
{"cmd", "CMD", pr_args, sr_cmd, 16, ARG, DEC, PO|UNLIMITED}, /*ucomm*/
|
{"cmd", "CMD", pr_args, sr_cmd, 27, ARG, DEC, PO|UNLIMITED}, /*ucomm*/
|
||||||
{"cmin_flt", "-", pr_nop, sr_cmin_flt, 1, 0, LNX, AN|RIGHT},
|
{"cmin_flt", "-", pr_nop, sr_cmin_flt, 1, 0, LNX, AN|RIGHT},
|
||||||
{"cnswap", "-", pr_nop, sr_nop, 1, 0, LNX, AN|RIGHT},
|
{"cnswap", "-", pr_nop, sr_nop, 1, 0, LNX, AN|RIGHT},
|
||||||
{"comm", "COMMAND", pr_comm, sr_cmd, 16, COM, U98, PO|UNLIMITED}, /*ucomm*/
|
{"comm", "COMMAND", pr_comm, sr_cmd, 15, COM, U98, PO|UNLIMITED}, /*ucomm*/
|
||||||
{"command", "COMMAND", pr_args, sr_cmd, 16, ARG, XXX, PO|UNLIMITED}, /*args*/
|
{"command", "COMMAND", pr_args, sr_cmd, 27, ARG, XXX, PO|UNLIMITED}, /*args*/
|
||||||
{"context", "CONTEXT", pr_context, sr_nop, 31, 0, LNX, ET|LEFT},
|
{"context", "CONTEXT", pr_context, sr_nop, 31, 0, LNX, ET|LEFT},
|
||||||
{"cp", "CP", pr_cp, sr_pcpu, 3, 0, DEC, ET|RIGHT}, /*cpu*/
|
{"cp", "CP", pr_cp, sr_pcpu, 3, 0, DEC, ET|RIGHT}, /*cpu*/
|
||||||
{"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */
|
{"cpu", "CPU", pr_nop, sr_nop, 3, 0, BSD, AN|RIGHT}, /* FIXME ... HP-UX wants this as the CPU number for SMP? */
|
||||||
@ -1321,8 +1370,8 @@ static const format_struct format_array[] = {
|
|||||||
{"tty4", "TTY", pr_tty4, sr_tty, 4, 0, LNX, PO|LEFT},
|
{"tty4", "TTY", pr_tty4, sr_tty, 4, 0, LNX, PO|LEFT},
|
||||||
{"tty8", "TTY", pr_tty8, sr_tty, 8, 0, LNX, PO|LEFT},
|
{"tty8", "TTY", pr_tty8, sr_tty, 8, 0, LNX, PO|LEFT},
|
||||||
{"u_procp", "UPROCP", pr_nop, sr_nop, 6, 0, DEC, AN|RIGHT},
|
{"u_procp", "UPROCP", pr_nop, sr_nop, 6, 0, DEC, AN|RIGHT},
|
||||||
{"ucmd", "CMD", pr_comm, sr_cmd, 16, COM, DEC, PO|UNLIMITED}, /*ucomm*/
|
{"ucmd", "CMD", pr_comm, sr_cmd, 15, COM, DEC, PO|UNLIMITED}, /*ucomm*/
|
||||||
{"ucomm", "COMMAND", pr_comm, sr_cmd, 16, COM, XXX, PO|UNLIMITED}, /*comm*/
|
{"ucomm", "COMMAND", pr_comm, sr_cmd, 15, COM, XXX, PO|UNLIMITED}, /*comm*/
|
||||||
{"uid", "UID", pr_euid, sr_euid, 5, 0, XXX, ET|RIGHT},
|
{"uid", "UID", pr_euid, sr_euid, 5, 0, XXX, ET|RIGHT},
|
||||||
{"uid_hack", "UID", pr_euser, sr_euser, 8, USR, XXX, ET|USER},
|
{"uid_hack", "UID", pr_euser, sr_euser, 8, USR, XXX, ET|USER},
|
||||||
{"umask", "UMASK", pr_nop, sr_nop, 5, 0, DEC, AN|RIGHT},
|
{"umask", "UMASK", pr_nop, sr_nop, 5, 0, DEC, AN|RIGHT},
|
||||||
|
Loading…
Reference in New Issue
Block a user