ps enhencements (posix syntax, and more)

Cyrille Lefevre cyrille.lefevre at laposte.net
Tue Apr 27 03:06:02 PDT 2004


here is a description of the last PR#64803 updates :

*** the kernel part has been reworked and validated in the last patch set.
the original PR describe OpenBSD -k as don't show kernel threads,
which is wrong, OpenBSD -K is FreeBSD -H except that system processes
aren't displayed by default while they are under FreeBSD.

added features :
-t '?' to select process not attached to a terminal (from older bsd).
tsid added in -j format string if -Q.
at last, implement KERN_PROC_SESSION in /sys/kern/kern_proc.c as
well as system processes filtering in KERN_PROC_PROC (not sure about
that). both features have not been tested yet, but will be soon.

bugs :
ttys are udev_t, not dev_t (this prevented the -t '?' to work).
pscomp() getpcpu * 100 or always 0.
also, uses typed variables instead of an integer generic one which is more
cleaner.

*** this patch set may be ignored as integrated in the last patch set.
added feature : don't show kernel threads by default unless -H is given.
(until this is implemented in the kernel)
bug fix : -L is missing a break.

*** this is the last patch set before dynamic sizing...
this patch set augment the previous ones except the libkvm and kernel part
which are fresh patches.

files impacted :

src/sys/conf/options
 cvs diff against -current
src/sys/sys/sysctl.h
 cvs diff against -current
src/sys/sys/user.h
 cvs diff against -current
src/sys/kern/kern_proc.c
 cvs diff against -current

src/lib/libkvm/Makefile
 cvs diff against -current
src/lib/libkvm/kvm_proc.c
 cvs diff against -current

src/bin/ps/Makefile
 cvs diff against -current (forgot to save it before any mods)
src/bin/ps/keyword.c
 diff against previous
src/bin/ps/ps.c
 diff against previous

kernel level added features :
KERN_PROC_SESSION, KERN_PROC_GID and KERN_PROC_RGID have been implemented at
kernel level as well as KERN_PROC_TTY_NODEV and KERN_PROC_TTY_REVOKED (the
last two are based on what NetBSD does but differently since we have to lock
p_session).
all these old/new sysctls may be turned on separately using kernel config
options as well as the ki_* added keywords.
KERN_PROC_PROC now handles KERN_PROC_INC_THREADS and, in this case, is
similar to KERN_PROC_ALL. P_SYSTEM processes aren't selected by default
(as OpenBSD).

PS : take care about the struct kinfo alignment. as currently implemented,
ki_spare has been validated under i386 and ia64 (and should work under alpha,
sparc64 and amd64), but not validated under alpha (don't have :(.

user level added features :
-t- to select processes which have been revoked from their terminal device
(from NetBSD and probably older bsd -- not verified), at kernel level only.
-G may now uses KERN_PROC_RGID if WITH_RGID is defined.
-s may now uses KERN_PROC_SESSION if WITH_SESSION is defined.
uses KERN_PROC_PROC alone if WITH_THREADS (KERN_PROC_ALL isn't needed anymore).
P_SYSTEM processes aren't selected by default if WITHOUT_SYSTEM is defined
(well, this is also implemented at kernel level, but for KERN_PROC_PROC only,
IMHO, this have to be implemented as a generic filter out before the big case).

user level modifications :
-t? may be compiled with or without kernel support if WITH_TTY is defined,
    but -t- can't.
some int variables have been changed to size_t (list->count, prtheader, i,
    lineno, nkept, nselectors).
-j now have sid by default.

user level bug fixes :
kvm_getprocs() error message fixed the way done in -current ps.
-o parsing has been reworked to conform to posix (the relaxed form has been
    WITH_RELAXED_FORMLAT #if'ed).
-tco have to use /dev/consolectl instead of /dev/console.
"0" (zero) flag has been added to *_fmtstr to better handle -Z (bsd) or
    -M (posix), so, label is always placed first.
-L was missing a break.
-u (posix) was filtering on real-uid instead of effective-uid.

the current size of ps is (optimized and stripped and w/o extra aliases) :
-current : 30788
this one : 38776

PS : Garance, if you want a fresh patch set, let me know.

Cyrille Lefevre.
-- 
home: mailto:cyrille.lefevre at laposte.net


More information about the freebsd-standards mailing list