From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 31 17:02:43 2007 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C726A16A406 for ; Wed, 31 Jan 2007 17:02:43 +0000 (UTC) (envelope-from waldeck@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 2547A13C428 for ; Wed, 31 Jan 2007 17:02:42 +0000 (UTC) (envelope-from waldeck@gmx.de) Received: (qmail 19463 invoked by uid 0); 31 Jan 2007 17:02:41 -0000 Received: from 82.141.47.50 by www120.gmx.net with HTTP; Wed, 31 Jan 2007 18:02:41 +0100 (CET) Content-Type: text/plain; charset="us-ascii" Date: Wed, 31 Jan 2007 18:02:41 +0100 From: "Dr. Markus Waldeck" In-Reply-To: <200701311442.l0VEgQbA093491@lurza.secnetix.de> Message-ID: <20070131170241.230960@gmx.net> MIME-Version: 1.0 References: <200701311442.l0VEgQbA093491@lurza.secnetix.de> To: freebsd-hackers@FreeBSD.ORG, waldeck@gmx.de X-Authenticated: #646368 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 1 Content-Transfer-Encoding: 7bit Cc: Subject: Re: top delay value X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jan 2007 17:02:43 -0000 > > > 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