Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2007 18:02:41 +0100
From:      "Dr. Markus Waldeck" <waldeck@gmx.de>
To:        freebsd-hackers@FreeBSD.ORG, waldeck@gmx.de
Subject:   Re: top delay value
Message-ID:  <20070131170241.230960@gmx.net>
In-Reply-To: <200701311442.l0VEgQbA093491@lurza.secnetix.de>
References:  <200701311442.l0VEgQbA093491@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
>  > > 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070131170241.230960>