top delay value

Dr. Markus Waldeck waldeck at gmx.de
Wed Jan 31 17:02:43 UTC 2007


>  > > typing "while :; do :; done".  There are a thousand ways

> No.  What I write above is not a "fork bomb", it's a single
> process which is wasting CPU in a busy loop.  It's exactly
> equivalent to top(1) with zero delay, except that top
> produces some output, while a busy loop does nothing useful
> at all.

I tested different shells and I found out that an exlicit sub shell
is required to let the shell fork:

while :; do (:); done

> By the way, you can "emulate" top(1) with run ps(1) in a
> shell loop like this (sh/zsh/ksh/bash syntax):
> 
> while :; do clear; ps -a; sleep 1; done
> 
> Do get zero delay, simply remove the sleep command from the
> loop ...  That's actually _worse_ than top(1) with zero
> delay, because kernel cycles are wasted for the fork() and
> exec() calls, not to mention I/O and other syscalls.  An
> empty shell loop ("while :; do :; done") doesn't perform
> any syscalls into the kernel.
> 
> Bottom line:  Disabling zero-delay in top doesn't buy you
> anything at all.  In fact, it might cause your users to
> invent work-arounds (for example shell loops) that waste
> even more resources.

So I have to limit the CPU time in /etc/login.conf and

        :cputime=300:\

invoke cap_mkdb /etc/login.conf.

-- 
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail


More information about the freebsd-hackers mailing list