From nobody  Wed Jul 23 22:18:35 1997
Received: (from nobody@localhost)
          by hub.freebsd.org (8.8.5/8.8.5) id WAA09252;
          Wed, 23 Jul 1997 22:18:35 -0700 (PDT)
Message-Id: <199707240518.WAA09252@hub.freebsd.org>
Date: Wed, 23 Jul 1997 22:18:35 -0700 (PDT)
From: denny1@home.com
To: freebsd-gnats-submit@freebsd.org
Subject: wish /bin/sleep handled fractions of a second.
X-Send-Pr-Version: www-1.0

>Number:         4154
>Category:       bin
>Synopsis:       wish /bin/sleep handled fractions of a second.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    ru
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 23 22:20:01 PDT 1997
>Closed-Date:    Thu Oct 28 11:05:20 PDT 1999
>Last-Modified:  Thu Oct 28 11:10:36 PDT 1999
>Originator:     Denny Gentry
>Release:        N/A
>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:

From: Jason Thorpe <thorpej@nas.nasa.gov>
To: denny1@home.com
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: bin/4154: wish /bin/sleep handled fractions of a second. 
Date: Wed, 23 Jul 1997 22:55:27 -0700

 On Wed, 23 Jul 1997 22:18:35 -0700 (PDT) 
  denny1@home.com wrote:
 
  >   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 on earth can you call such a script "portable" if it clearly uses
 something not specified in POSIX?
 
 Jason R. Thorpe                                       thorpej@nas.nasa.gov
 NASA Ames Research Center                               Home: 408.866.1912
 NAS: M/S 258-6                                          Work: 415.604.0935
 Moffett Field, CA 94035                                Pager: 415.428.6939

From: FreeBSD Technical Reader <kernel@acromail.ml.org>
To: denny1@home.com
Cc: freebsd-gnats-submit@FreeBSD.ORG, GNATS Management <gnats@FreeBSD.ORG>,
        freebsd-bugs@hub.freebsd.org
Subject: Re: bin/4154: wish /bin/sleep handled fractions of a second.
Date: Sat, 26 Jul 1997 12:29:07 -0700 (PDT)

 Wouldn't you want to use usleep() for that only thing is that I think that
 is good only about to 0.02 seconds generally unless you change HZ which
 messes up some other things (I wonder if these would be fixed by a make
 world)
 
 
 On Wed, 23 Jul 1997 denny1@home.com wrote:
 
 > 
 > >Number:         4154
 > >Category:       bin
 > >Synopsis:       wish /bin/sleep handled fractions of a second.
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Class:          change-request
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Wed Jul 23 22:20:01 PDT 1997
 > >Last-Modified:
 > >Originator:     Denny Gentry
 > >Organization:
 > >Release:        N/A
 > >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);
 > >Audit-Trail:
 > >Unformatted:
 > 
 
State-Changed-From-To: open->feedback 
State-Changed-By: joerg 
State-Changed-When: Sun Oct 12 14:40:16 MEST 1997 
State-Changed-Why:  

Feedback request sent to -hackers for whether to accept or reject the 
suggestions. 
State-Changed-From-To: feedback->suspended 
State-Changed-By: phk 
State-Changed-When: Tue Apr 14 12:18:38 PDT 1998 
State-Changed-Why:  
->suspended. 
Responsible-Changed-From-To: freebsd-bugs->ru 
Responsible-Changed-By: ru 
Responsible-Changed-When: Fri Sep 24 14:23:17 PDT 1999 
Responsible-Changed-Why:  
I am working on this one. 
State-Changed-From-To: suspended->closed 
State-Changed-By: ru 
State-Changed-When: Thu Oct 28 11:05:20 PDT 1999 
State-Changed-Why:  
Sleep(1) now handles fractions of a second. 
>Unformatted:
