From owner-freebsd-current Wed Nov 13 0: 4:30 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 534E337B401 for ; Wed, 13 Nov 2002 00:04:29 -0800 (PST) Received: from axl.seasidesoftware.co.za (axl.seasidesoftware.co.za [196.31.7.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 42A1F43E4A for ; Wed, 13 Nov 2002 00:04:28 -0800 (PST) (envelope-from sheldonh@starjuice.net) Received: from sheldonh by axl.seasidesoftware.co.za with local (Exim 4.10) id 18BsVd-0000VW-00; Wed, 13 Nov 2002 10:04:25 +0200 Date: Wed, 13 Nov 2002 10:04:25 +0200 From: Sheldon Hearn To: Nate Lawson Cc: current@freebsd.org Subject: Re: sleep(1) behavior Message-ID: <20021113080425.GO1278@starjuice.net> Mail-Followup-To: Nate Lawson , current@freebsd.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.1i X-Scanner: exiscan for exim4 (http://duncanthrax.net/exiscan/) *18BsVd-0000VW-00*.pD0/i5bTTU* Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On (2002/11/12 16:37), Nate Lawson wrote: > I've found an interesting contradiction and was wondering what behavior > sleep should have. It checks for a command line flag with getopt(3) and > exits with usage() if it finds one. However, it then checks for a '-' or > '+' sign. If negative, it behaves like "sleep 0" and exits > immediately. This case can almost never be triggered since the > getopt(3) will catch the minus sign, even if a digit follows it. > > Current behavior: > sleep 0 = exits immediately > sleep -1 = exits with usage() > sleep -f = exits with usage() > sleep " -1" = exits immediately and is the only way I know to trigger > the negative case. > > What is the standard, desired behavior? IEEE Std 1003.2-1992 says: time A nonnegative decimal integer specifying the number of seconds for which to suspend execution. I think it's pretty clear that negative time arguments to sleep(1) are not portable. Ciao, Sheldon. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message