NetBSD Problem Report #3914
Received: (qmail 19186 invoked from network); 24 Jul 1997 05:18:43 -0000
Message-Id: <199707240519.WAA17293@nooksack.ldc.cs.wwu.edu>
Date: Wed, 23 Jul 1997 22:19:05 -0700 (PDT)
From: denny1@home.com
To: gnats-bugs@gnats.netbsd.org
Subject: wish /bin/sleep handled fractions of a second
X-Send-Pr-Version: www-1.0
>Number: 3914
>Category: bin
>Synopsis: wish /bin/sleep handled fractions of a second
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Wed Jul 23 22:20:01 +0000 1997
>Closed-Date: Mon Aug 04 01:17:46 +0000 1997
>Last-Modified: Fri Mar 30 09:30:02 +0000 2012
>Originator: Denny Gentry
>Release: 1.2G
>Organization:
>Environment:
Fix was developed on OpenBSD.
>Description:
I have often wished /bin/sleep could sleep for less than one second,
in the inner loop of a script which I want to slow down slightly.
Such a feature would be an extension to POSIX, which deals only
with full seconds.
This has been implemented in OpenBSD. The crucial portion of the
code I submitted there has been pasted below. It would be nice to
get such an extension adopted more widely in *BSD, so portable scripts
could use it.
>How-To-Repeat:
/bin/sleep 0.5
wish it worked the way you want.
>Fix:
/* $OpenBSD: sleep.c,v 1.6 1997/06/29 08:09:21 denny Exp $ */
cp = *argv;
while ((*cp != '\0') && (*cp != '.')) {
if (!isdigit(*cp)) usage();
secs = (secs * 10) + (*cp++ - '0');
}
/* Handle fractions of a second */
if (*cp == '.') {
*cp++ = '\0';
for (i = 100000000; i > 0; i /= 10) {
if (*cp == '\0') break;
if (!isdigit(*cp)) usage();
nsecs += (*cp++ - '0') * i;
}
}
rqtp.tv_sec = (time_t) secs;
rqtp.tv_nsec = nsecs;
if ((secs > 0) || (nsecs > 0))
(void)nanosleep(&rqtp, NULL);
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: perry
State-Changed-When: Sun Aug 3 18:17:46 PDT 1997
State-Changed-Why:
Fixed, but differently than suggested.
May the spirits of Ken and Dennis forgive me.
From: "Jukka Ruohonen" <jruoho@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/3914 CVS commit: src
Date: Fri, 30 Mar 2012 09:27:11 +0000
Module Name: src
Committed By: jruoho
Date: Fri Mar 30 09:27:10 UTC 2012
Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
Added Files:
src/tests/bin/sleep: Makefile t_sleep.sh
Log Message:
Add regression tests for PR bin/3914 and PR bin/27140.
To generate a diff of this commit:
cvs rdiff -u -r1.461 -r1.462 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.70 -r1.71 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r0 -r1.1 src/tests/bin/sleep/Makefile \
src/tests/bin/sleep/t_sleep.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.