Commit Graph

94 Commits

Author SHA1 Message Date
will
a9f5ed66a5 Fix the exit code for the case where nentries == 0; if a PID doesn't exist,
ps(1) should not be returning a success code (0), it should return an
error code (1).  This was fixed on OpenBSD over 3 years ago.

PR:		19069
Submitted by:	Jim Sloan <odinn@atlantabiker.net>
Reviewed by:	rwatson
2000-07-08 05:13:10 +00:00
peter
938bef9779 I'm probably jumping the gun, but what the heck, this is -current.
Turn off setgid-kmem for /bin/ps, it's now quite functional without it.
ps no longer needs /dev/*mem or /proc.  (It will still use some /proc
files if they are available for -e, but it's not required, so it'll
happily run in a jail or chroot).

The proc stats are now part of eproc (obtained via sysctl) and no longer
needs to beat up the u-page reading code and the problems with that.

This also has the side effect of disabling 'ps -e' for normal users
*EXCEPT* when looking at their own processes.  ie: they can see
environments in processes with their uid, enforced by the ownership of
/proc/*/mem.  Root can still see them all, as it can open all /proc/*/mem.
1999-11-17 13:37:30 +00:00
peter
0f063714b6 Use eproc.e_stats, not a series of crude hacks to fetch it from the u-area.
Also, fix some indentation that got messed up somehow..
1999-11-17 12:52:42 +00:00
phk
9e8e07135f Introduce commandline caching in the kernel.
This fixes some nasty procfs problems for SMP, makes ps(1) run much faster,
and makes ps(1) even less dependent on /proc which will aid chroot and
jails alike.

To disable this facility and revert to previous behaviour:
        sysctl -w kern.ps_arg_cache_limit=0

For full details see the current@FreeBSD.org mail-archives.
1999-11-16 20:31:58 +00:00
kris
66eb9e9f62 Typo (appropiate -> appropriate)
Obtained from:	OpenBSD (inspired by)
1999-11-15 03:37:57 +00:00
peter
3b7c52fb9a $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
kris
a5048ed9e5 Correct reference to the obsolete vadvise() to madvise() (with appropriate
arguments)

PR:		11586
Submitted by:	David Gilbert <dgilbert@velocet.ca>
Reviewed by:	Doug Rabson
1999-06-30 11:50:09 +00:00
kris
935bd87c22 Various spelling/formatting changes.
Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
1999-05-08 10:22:15 +00:00
phk
79134080a0 This Implements the mumbled about "Jail" feature.
This is a seriously beefed up chroot kind of thing.  The process
is jailed along the same lines as a chroot does it, but with
additional tough restrictions imposed on what the superuser can do.

For all I know, it is safe to hand over the root bit inside a
prison to the customer living in that prison, this is what
it was developed for in fact:  "real virtual servers".

Each prison has an ip number associated with it, which all IP
communications will be coerced to use and each prison has its own
hostname.

Needless to say, you need more RAM this way, but the advantage is
that each customer can run their own particular version of apache
and not stomp on the toes of their neighbors.

It generally does what one would expect, but setting up a jail
still takes a little knowledge.

A few notes:

   I have no scripts for setting up a jail, don't ask me for them.

   The IP number should be an alias on one of the interfaces.

   mount a /proc in each jail, it will make ps more useable.

   /proc/<pid>/status tells the hostname of the prison for
   jailed processes.

   Quotas are only sensible if you have a mountpoint per prison.

   There are no privisions for stopping resource-hogging.

   Some "#ifdef INET" and similar may be missing (send patches!)

If somebody wants to take it from here and develop it into
more of a "virtual machine" they should be most welcome!

Tools, comments, patches & documentation most welcome.

Have fun...

Sponsored by:   http://www.rndassociates.com/
Run for almost a year by:       http://www.servetheweb.com/
1999-04-28 11:38:52 +00:00
peter
b6ac417ceb Update p_flags doc. 1999-04-06 03:18:57 +00:00
peter
d233b6a696 Look at p_lock instead of P_NOSWAP etc as an indicator of unswappability.
(While here, put a #ifndef pgtok around the macro that gets a redefinition
 warning)
1999-04-06 03:17:57 +00:00
wpaul
69b98e37f3 On FreeBSD/alpha, ps(1) does not correctly report process start times
and CPU runtime because it can't access the user area via /proc/<pid>/mem.
This is because the uarea is not mapped into the process address space
at USRSTACK on the alpha like it is on the x86.

Since I'm haven't been able to wrap my brain around the VM system enough
to be able to figure out how to achieve this mapping, and since it's
questionable that such an architectural change is correct, I implemented
a workaround to allow ps(1) to read the uarea from /dev/kmem using
kvm_read() instead of from the process address space via kvm_uread().
The kludge is hidden inside #ifdef __alpha__/#endif so as not to impact
the x86. (Note that top(1) probably uses this same gimmick since it works
on FreeBSD/alpha.)

Reviewed by: dfr
1999-04-01 14:45:18 +00:00
julian
77672a61df Enable Linux threads support by default.
This takes the conditionals out of the code that has been tested by
various people for a while.
ps and friends (libkvm) will need a recompile as some proc structure
changes are made.

Submitted by:	"Richard Seaman, Jr." <dick@tar.com>
1999-01-26 02:38:12 +00:00
julian
26938d7eec Re-enable the options in ps(1) that were disabled with the Linux
threads support.

Submitted by:	"Richard Seaman, Jr." <dick@tar.com>
1999-01-13 03:11:43 +00:00
julian
f271b9be8e Reviewed by: Luoqi Chen, Jordan Hubbard
Submitted by:	 "Richard Seaman, Jr." <lists@tar.com>
Obtained from:	linux :-)

Code to allow Linux Threads to run under FreeBSD.

By default not enabled
This code is dependent on the conditional
COMPAT_LINUX_THREADS (suggested by Garret)
This is not yet a 'real' option but will be within some number of hours.
1998-12-19 02:55:34 +00:00
bde
67c1d3cb36 Fixed -Wall regression (broken in rev.1.12). Removed unused includes. 1998-12-07 10:25:48 +00:00
dfr
bfeed1c924 Fix formatting of %CPU value on alpha.
Submitted by: Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp>
1998-11-25 09:34:00 +00:00
dfr
ba505a4c7c Portability fixes when sizeof(int) != sizeof(long). 1998-09-14 08:32:20 +00:00
bde
4d0d1bdf0d Fixed breakage of %CPU and %MEM in the previous commit. sysctlbyname()
was called with wrong args so it always failed.

PR:		7881
1998-09-10 18:06:28 +00:00
phk
1a1b91e398 Pick up kernel variables/constants using sysctl rather than through /dev/mem
Use /dev/null for opening the kvm library, we don't need access to /dev/mem
anymore.

ps can now run without the setgid(kmem) bit.  If it does it will not be
able to show argv/envp for another uid's processes unless you are root.
1998-06-30 21:34:14 +00:00
bde
846df0ccd8 Fixed printf format errors (second round with non-i386 typedefs). 1998-06-28 21:05:48 +00:00
bde
ae0ea8e208 Oops, the previous log message should have read "Fixed type mismatches -
don't assume that time_t is long".
1998-06-28 18:26:18 +00:00
bde
cd369d3872 Fixed printf format errors. 1998-06-28 18:19:13 +00:00
jkoshy
9ae2dba8f6 Remove compile time dependency on ARG_MAX.
PR: 1791 (partial)
Reviewed by: Bruce Evans <bde@freebsd.org>, Tor Egge <tegge@freebsd.org>
1998-06-17 11:33:10 +00:00
jkoshy
fb4783cb34 Fix errors that crept into the previous commit. 1998-06-04 07:02:59 +00:00
jkoshy
324c3d8c89 1. ps' output now shows 3 characters in the TT' field, not 2, after
rev 1.6 of "ps.c".
2. Reword description of `-f' option.

PR: 5340
Submitted by: Jorge Goncalves <j@bug.fe.up.pt>
1998-06-04 06:46:13 +00:00
bde
aa0dee5e71 Fixed imperfections in previous commit (a poor variable name,
excessive 64-bit arithmetic, and excessive changes).
1998-05-31 12:09:50 +00:00
phk
69ad703802 Some cleanups related to timecounters and weird ifdefs in <sys/time.h>.
Clean up (or if antipodic: down) some of the msgbuf stuff.

Use an inline function rather than a macro for timecounter delta.

Maintain process "on-cpu" time as 64 bits of microseconds to avoid
needless second rollover overhead.

Avoid calling microuptime the second time in mi_switch() if we do
not pass through _idle in cpu_switch()

This should reduce our context-switch overhead a bit, in particular
on pre-P5 and SMP systems.

WARNING:  Programs which muck about with struct proc in userland
will have to be fixed.

Reviewed, but found imperfect by:       bde
1998-05-28 09:30:28 +00:00
steve
846f9321d4 If no value is present for the login name set it to '-'.
Also pretty-up the display of 'ps -Ortprio'.

PR:		4947
Submitted by:	Martin Kammerhofer <dada@sbox.tu-graz.ac.at>
1998-05-25 05:07:18 +00:00
charnier
80458a8e0a Correct use of .Nm. Add rcsid. 1998-05-15 06:30:58 +00:00
dima
ecf2a65e4c Add 'f' flag to the optstring. 1998-02-18 22:49:58 +00:00
dima
3d91e52df3 cosmetic change for optstring 1998-02-18 22:45:22 +00:00
dyson
ccb56de039 Display VSZ much more accurately now. 1998-02-02 05:16:42 +00:00
dyson
44ee994858 Document the new -f flag.
PR:	5196
Submitted by:	Matt Dillon <dillon@best.net>
1997-12-05 07:35:31 +00:00
dyson
7df966457d Add an option to building PS, so that the upages are explicitly paged in only
for users who are root, or in group wheel.  This is useful on large timesharing
systems where a PS command can cause the system to grind to a halt.  The
ability to get the information isn't diminished for those who really need the
additional detail (administrators.)  Normal users won't see any difference unless
the processes are swapped out.  The "really get it mode" is invoked by the
use of an additional flag in the command string "-f".  New/old behavior is
selectable with a compile option.

PR:		5196
Submitted by:	Matt Dillon <dillon@best.net>
1997-12-05 07:33:40 +00:00
jlemon
b5bff2d390 Document correct option in manual page.
PR:		3769
Submitted by:	johnp@lodgenet.com
1997-08-19 21:52:07 +00:00
steve
89684c8d1d Use -I${.CURDIR}/../../sys so that the path is relative
to the source code directory.

Submitted by:	bde
1997-08-13 17:35:00 +00:00
steve
532601c3fa Oops, add #include's (forgotten in last commit) to make this
compile again.
1997-08-11 02:41:02 +00:00
steve
020120ed08 Use -I../../sys instead of -I/sys. 1997-08-11 02:36:09 +00:00
steve
7b560b7a4e Remove #ifdef NEWVM code and remove extra "key.name = p" line. 1997-08-11 02:35:16 +00:00
steve
aae937eff0 Fix seg fault when invalid keywords are used.
PR:		bin/4253
Submitted by:	Jesse Rosenstock <jmr@ugcs.caltech.edu>
1997-08-11 02:29:50 +00:00
peter
4798973d71 Fix "lstart". (Displays "19" rather than time)
PR: 4206
Submitted by: Tetsuya Furukawa <tetsuya@secom-sis.co.jp>
1997-08-03 08:33:17 +00:00
peter
c8da6d7fe6 Kill #ifndef NEWVM etc. It affected a lot of other things besides
VM structure (eg: credentials etc) and it's highly unlikely we'll ever
get to see the "tainted" BSD<=4.3 VM code in public use.  Although it
indicated the way some things used to be done, it obfuscates things too
much.
1997-08-03 08:25:01 +00:00
bde
d04c5a7006 devname.c moved to libc before Lite1 and isn't in ps in Lite2. 1997-07-13 07:43:41 +00:00
charnier
3f6611f8d3 Cosmetic change in usage string. 1997-06-06 06:40:06 +00:00
jkh
6fbecfb144 Dynamically adjust size of displayed username to the longest username which
appears, not the longest _maximum_ username (this should probably also go
into 2.2, for the day when we bump up the username length there too).

Submitted-By: Terry Lambert <terry@lambert.org>
1997-04-29 05:26:05 +00:00
jdp
ce525b762d When "-c" is specified, don't pad the command with spaces if it is
the last field on the line.  "ps -axlc" was needlessly wrapping
around on 80-character windows.
1997-04-16 16:08:11 +00:00
imp
cdc0e920d8 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-28 15:24:41 +00:00
guido
ee328d1053 Fix buffer overflow (probably unexploitable). 1997-03-10 19:10:08 +00:00
ache
ef8eca45e6 Big usernames fixes 1997-03-04 00:33:56 +00:00