Commit Graph

45 Commits

Author SHA1 Message Date
lukem b8a6769184 fix minor WARNS=2 2001-11-03 13:21:09 +00:00
wiz 8c6310c4a3 Remove duplicate `if'. Noted by Geoff C. Wing in bin/13551. 2001-07-30 16:22:49 +00:00
matt c6458f33d8 Add a small optimizetion in savevars(). break out of the loop once needcomm
is set since setting it multiple times only wastes cpu time.
2001-07-20 21:59:58 +00:00
cyber 428f40d685 If there were no processes to list, it meant that our criteria failed
and didnt match anything.  Dont make our caller think we succeeded.
2001-06-14 19:04:49 +00:00
simonb 643cb3c341 Don't check namelist when choosing to use the sysctl interface. 2000-06-16 03:51:00 +00:00
simonb d530ee00d1 Fix handling of "ps U<user>" where <user> ended it 't' - now if the
first argument doesn't start with a '-' and ends in 't', the 't' only
gets converted to a 'T' (for listing processes on the current tty)
if it doesn't contain any other command line option characters that
take an argument.  Problem noticed by ITOH Yasufumi on tech-userlevel.

If the 'start' format was the last column, the width wouldn't be set
and started() output a zero length string instead of a string the right
length - fix header width calculations so the the last column is handled
the same all others.  This only showed up for 'start' because started()
knew that the column header is the same width and the field itself...

Update copyrights.
2000-06-08 13:30:39 +00:00
simonb a98dd470c6 Calculate field widths on the fly so that all columns line up nicely
and make more effective use of screen real estate when some columns
(eg USER and VSZ) didn't need the full default width.
2000-06-07 04:57:59 +00:00
simonb fd521aefe9 Use new sysctl/kvm interfaces. This will stop the "proc size mismatch"
errors when internal kernel structures change size.  Also remove
the sgid bit - all live kernel data is accessed through the sysctl
interface.
2000-05-26 03:04:28 +00:00
abs 22cfbf2cbb If ps cannot get the terminal size from STDOUT, it tried STDERR and STDIN.
What this does to the POLS when a script that is parsing ps output just happens
to run in a narrow terminal cannot be described in polite company.
If STDOUT is not a tty, leave width at 80.
2000-04-29 00:18:48 +00:00
simonb 8384a1bbb8 Use tty "?" to select processes with no controlling tty and tty "-" to
select processes with a revoked controlling tty.

Idea from SunOS/Solaris, suggested by Alexis Rosen.
2000-04-15 04:40:46 +00:00
chs 233639846d make -M imply -K. the current system is not likely to be
a reasonable approximation of a crash dump.
2000-04-10 06:37:37 +00:00
hubertf b8a04b1a7e Document -U switch (displays processes belonging to given user/uid).
Reported in PR 8943 by WL <wliao@dura.spc.uchicago.edu>
1999-12-04 01:23:09 +00:00
simonb 5801c247fa "ps -e" only shows the environment for the processes owned by the
current user id or all process if run by root.

Fixes PR security/5967 from Todd Vierling.
1999-12-03 02:16:41 +00:00
drochner 85cbf55d16 Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
1999-11-09 15:06:30 +00:00
jdolecek a5ae7c6ca4 command(): don't start using procfs_getargv() instead of kvm_getargv()
just because the latter returned a NULL - that may normally happen,
when the process is, for example, a kernel thread

procfs_getargv(): if the name is brackened in '(' and ')', just
	return NULL immediately - the code in command() will DTRT
	and the output will be same for procfs- and kvm- based lookup
	in all cases
1999-10-15 20:39:52 +00:00
jdolecek e52880e76a getkinfo_kvm(): fix bug in previous - handled size_t i as if it would be signed
saveuser(): don't check kd - if we get here, kd is never NULL
1999-10-15 20:01:33 +00:00
jdolecek f848d2ec0c When using the procfs for extracting process information, extract
also process start time, process arguments and session leadership status.

The procfs fallback is also used when kvm_openfiles() completely fails
(e.g. when /dev/mem is not readable).

Solves PR 7772, though the final implementation is different.
1999-10-15 19:31:24 +00:00
bgrayson 05e0706ac9 Minor fixes:
1.  Use statfs() to verify that /proc is a procfs.
2.  Add -K option to disable /proc-based method.
3.  Make warnings less verbose, but still accurate.
1999-03-27 21:38:08 +00:00
bgrayson be8534f744 Added experimental fallback /proc-based lookup. Warnings are printed when the
fallback method is used, as the results could be untrustworthy if an
intruder is present.  It is highly likely that NetBSD-1.5 will have
an improved kvm interface for reading process information, at which
point this code can be garbage-collected.  Also added a word to the
man page -x option description while I was here.
1999-03-26 22:36:02 +00:00
kim 26cc4401e8 Fixed segfaulting for "ps -T". There is no optarg with -T, so instructions
under label "tty:" need to use ttname instead.
1999-01-04 16:37:28 +00:00
mycroft 975ed85295 Add a -U option to select by user/uid. 1998-07-28 18:54:02 +00:00
mycroft ee9e50eacb Be more retentive about use of NOTREACHED and noreturn. 1998-07-28 11:41:40 +00:00
mycroft 9dc385beb1 Delint. 1998-07-28 05:31:22 +00:00
mycroft 0e2f9ea923 __AUDIT__ cleanup. 1998-07-27 17:06:48 +00:00
mrg 80efe80bc9 - change setgid kmem programs (that lend themselves to this) so setegid(getgid())
and the top, and then set the effective gid back to kmem around the call to
  kvm_openfiles().  this reduces the time group kmem is available.
- for those above that also allow this, setgid(getgid()) after the call to
  kvm_openfiles() to fully revoke priviledges.
- some KNF
- use err(3) over fprintf(3) in some places
1998-07-06 07:50:18 +00:00
lukem a234ba3ffe getopt returns -1 not EOF
cleanup manpage
1997-09-14 08:57:37 +00:00
christos 78295c8bc1 Fix compiler warnings
Add WARNS=1
1997-07-20 20:37:53 +00:00
mrg ecdc59670c note that strcpy is safe. 1997-04-21 05:28:43 +00:00
pk bf18a93a17 Message buffer passed to kvm_openfiles() should _POSIX2_LINE_MAX long; PR#3266 1997-02-28 13:34:50 +00:00
thorpej 83e59fbba8 Fix SEGV when kludging old-style options.
From Greg Stark <gsstark@mit.edu>, PR #2550.
1996-09-27 02:59:53 +00:00
mycroft 3541700d61 Create and strvis(3) the argument and environment lists only as needed.
Do not keep extra copies around.
1995-05-18 20:33:20 +00:00
mycroft d70850c69c Gather the argument and environment lists when we actually want to print them. 1995-05-18 14:37:03 +00:00
cgd 49f0ad8601 convert to new RCS id conventions. 1995-03-21 09:01:59 +00:00
mycroft 07cdfa9cd1 Integrate `-c' option, from Arne Juul. 1994-09-16 22:23:29 +00:00
cgd 4d1457ce4e clean up import 1994-05-09 03:31:07 +00:00
cgd 25718695be update for changed flags 1994-05-05 02:04:10 +00:00
cgd cd68b34ae6 fix from Thomas Eberhardt <thomas@mathematik.uni-Bremen.de>:
don't try to display the resident text size; we can't do that anymore
1993-10-07 00:45:59 +00:00
mycroft 8542364e07 Add RCS identifiers. 1993-08-01 18:49:50 +00:00
cgd 40194b0e50 from Brian Somers <brian@awfulhak.demon.co.uk>:
The kvm entry isn't updated for command unless 'time' is given,
therefore
	ps -o command
outputs blank lines [or, in NetBSD, seg faults]
	ps -o time,command
works.
1993-07-19 11:02:10 +00:00
cgd 4434a6ed53 fix alien 'w' handling. you really don't want to know... 1993-07-11 17:34:29 +00:00
cgd 6ed1026d12 add support and documentation for the 'e' option, to print out
the process environment.
1993-06-01 01:38:28 +00:00
cgd 06be60083d changed "Id" to "Header" for rcsids 1993-03-23 00:22:59 +00:00
cgd 346aa5dd48 added rcs ids to all files 1993-03-22 08:04:00 +00:00
cgd e541169ce2 after 0.2.2 "stable" patches applied 1993-03-21 18:04:42 +00:00
cgd 61f282557f initial import of 386bsd-0.1 sources 1993-03-21 09:45:37 +00:00