[net.sources.bugs] SPS - a useful replacement for ps

sean@ukma.UUCP (Sean Casey) (06/28/85)

Sps is fast, easy to understand, wonderful, and free, but.....

% sps vt h1
Ty User     Status Fl Nice Virtual Resident %M  Time Child %C Proc# Command
h1 sean     PAUSE          124+ 17   70+ 17  2  87.7        0 24140 sysline -b 
h1 sean     PAUSE           68+ 65   42+ 65  1  68.7+ 12 M  0 24818 -csh 
h1  *root   PAUSE           62+ 65   38+ 65  1  27.5+332.6  1 26167 -u 
h1   *      STOP            78+ 23   37+ 19  1  10.1        0 27006 postnews 
h1    |     STOP           176+108  127+ 94  4  19.7        0 27117 /usr/ucb/vi
h1.  *      RUN       -20  238+ 22   34+ 14  1   2.0        0 27148 sps vt h1 
80 (5838k) processes, 1 (260k) busy, 55 (1340k) loaded, 24 (491k) swapped
		       ^^
		       ||

Look at the nice figure for sps.  Isn't that a little extreme?  I like fast
response as much as anyone, but at the ultimate expense of others?

Just thought I'd warn ya.


P.S.  For a not good time, try "sps adefgvwr > /dev/null &"

robert@hslrswi.UUCP (Robert Ward) (07/03/85)

Sean Casey (sean@ukma.UUCP) points out that sps runs at nice -20
and hence runs fast at the expense of other users. He even goes on
to point out that typing "sps adefgvwr >/dev/null &" can have pretty
dire consequences for everyone else.

Well, of course, he is absolutely right. Sps does renice itself not
just to go faster but also in an attempt to look at separate kernel data
structures before they are changed too much or become too inconsistent
with one another.  In practise, however, it doesn't seem to affect the
response time of sps too much whether it runs at nice -20 or nice 0.

One solution, suggested by Jeffrey Mogul, is to renice sps only for root.
This also means that sps need not be a setuid program.
Here is the diff for main.c -

26,28c26,29
< 	/* Renice as fast as possible for root (Suggested by Gregorio!mogul) */
< 	if ( !getuid() )
< 		(void)nice( -40 ) ;
---
> # ifndef TRACE
> 	(void)nice( -40 ) ;
> 	(void)setuid( getuid() ) ;
> # endif

Personally, I don't think it matters much either way.

(Robert Ward, Hasler AG, Belpstrasse 23, CH-3000 Bern 14, Switzerland).

kay@warwick.UUCP (Kay Dekker) (07/08/85)

In article <121@hslrswi.UUCP> robert@hslrswi.UUCP (Robert Ward) writes:

>One solution, suggested by Jeffrey Mogul, is to renice sps only for root.
>This also means that sps need not be a setuid program.

*Need* not, admittedly: however, that means that /dev/drum, /dev/mem and
/dev/kmem all need to be generally readable.  And I seem to remember that
that wouldn't be a good idea ... or am I wrong?

							Kay.
-- 
"In a world without rational structure, even the most bizarre events must
eventually take place."   -- Philip Avalon, "On the Resurrection of Reagan"
			
			... mcvax!ukc!warwick!flame!kay

gordon@sneaky (07/09/85)

> /* Written  2:43 pm  Jul  3, 1985 by hslrswi.U!robert in sneaky:net.sources.bu */
> ...
> One solution, suggested by Jeffrey Mogul, is to renice sps only for root.
> This also means that sps need not be a setuid program.
> ...
> 
> (Robert Ward, Hasler AG, Belpstrasse 23, CH-3000 Bern 14, Switzerland).
> /* End of text from sneaky:net.sources.bu */

I sure hope sps still needs to be a privileged program!  Maybe on your system
you can get away with using setgid sys instead of setuid root, but if your
system has /dev/mem, /dev/kmem, and/or /dev/swap readable by everyone, you
are just asking to have your root password stolen by someone's "clist watcher"
program.

Sps, by the way, should do its setuid(getuid()) AFTER it gets /dev/mem, 
/dev/kmem, and /dev/swap open.


					Gordon Burditt
					...!convex!ctvax!trsvax!sneaky!gordon
					...!ihnp4!sys1!sneaky!gordon

thomas@utah-gr.UUCP (Spencer W. Thomas) (07/10/85)

In article <2288@flame.warwick.UUCP> kay@warwick.UUCP (Kay Dekker) writes:
>>This also means that sps need not be a setuid program.
>
>*Need* not, admittedly: however, that means that /dev/drum, /dev/mem and
>/dev/kmem all need to be generally readable.  And I seem to remember that
>that wouldn't be a good idea ... or am I wrong?

You can take the solution we have used for some time -- make /dev/drum,
... readable by a special group (we call it MEM), but not by the general
public.  Then, make ps, pstat, ... setGID to MEM.

-- 
=Spencer   ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA)
	"You don't get to choose how you're going to die.  Or when.
	 You can only decide how you're going to live." Joan Baez