svn commit: r334552 - head/usr.bin/top

Warner Losh imp at bsdimp.com
Mon Jun 4 15:55:54 UTC 2018


On Sun, Jun 03, 2018 at 05:07:46AM +0000, Eitan Adler wrote:
> > New Revision: 334552
> > URL: https://svnweb.freebsd.org/changeset/base/334552
> >
> > Log:
> >   top(1): remove chdir to /
> >
> >   While this came out of a conversation in IRC, it turn out that some
> >   people don't like it. Since this was a courtesy feature, just remove
> it.
>

At first I thought you were nuts to remove it, since I thought this was a
wise change. However, I've changed my mind.

I've done some research behind this practice. A long time ago, it used to
be critical to the operation of the system: long running processes could
prevent a reboot. The 7th Edithion and earlier didn't even have a reboot
system call[*]. In System III and original System V based systems, you even
had to cd / before doing a shutdown. Otherwise the umounts of all the
filesystems except / would fail. There were no forcing provisions in the
code at that time. Long running processes would cd to / to avoid problems
with people needing to unmount a filesystem and secondarily to ensure that
the umounts would work if there were issues with the process dying at
reboot time. Somewhere around SysV r3 or so, these restrictions were
lessoned and by the time Solaris forked from SysV r4, they were mostly
gone. BSD kernels appear to have had similar issues, but they were fixed
(or became moot) very early on (maybe between 2.8 and 2.9, google isn't as
helpful as I'd had hoped here, and I didn't want to sink a ton of time
reading code on TUHS).

Fast forward to today, and they are unneeded. There's no issue with reboot.
There can be minor issues with umounting filesystems. fstat(1) can be used,
though it's a bit cumbersome, to find stray references.

Warner

[*] OK, a system call number was reserved for reboot, but it wasn't
implemented.


More information about the svn-src-all mailing list