[comp.unix.questions] ps -s /dev/null kills system?

mellman@ttrdd.UUCP (09/24/87)

ps(1) says, about the -s option:

"Use the file *swapdev* in place of -/dev/swap-.  This is useful when
examining a *corefile*; a *swapdev* of -/dev/null- will cause the user
block to be zeroed out."

Is this for real?  What is the *user block*, anyway?  Presumably, if it's
a disk block, you have to be the super-user to have write access to disk,
but even then...

guy%gorodish@Sun.COM (Guy Harris) (09/27/87)

> ps(1) says, about the -s option:
> 
> "Use the file *swapdev* in place of -/dev/swap-.  This is useful when
> examining a *corefile*; a *swapdev* of -/dev/null- will cause the user
> block to be zeroed out."
> 
> Is this for real?

Yes.

> What is the *user block*, anyway?

In effect, it's the kernel's per-process data and stack segment for a process.

> Presumably, if it's a disk block, you have to be the super-user to have
> write access to disk, but even then...

"Will cause the user block to be zeroed out" is a poor way of describing what
is meant here.

"ps" has to be able to *read* the "user block" of a process in order to
determine certain things about the process; when examining a kernel crash dump
(i.e., a "corefile"), it can get the user block for processes that were in core
from that crash dump, but it can't always get the user block for processes that
were swapped out.  When the system crashes, the contents of physical memory are
generally saved and later stored into the corefile, but the contents of the
swap area are *not* generally saved.  As such, "ps" may get confused by
swapped-out processes, as it will normally try to get their user blocks from
the normal swap space.  However, what's on that swap space now has nothing to
do with what was there when the system crashed, unless you're very lucky.

All that "will cause the user block to be zeroed out" means here is that "ps"
will *think* that the user block for swapped-out processes is full of zeroes,
because it will read it from "/dev/null" rather than from the swap space.  It
does *not* mean that "ps" will go out and zero the swap space.
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com