atom feed12 messages in org.freebsd.freebsd-bugsRe: bin/4154: wish /bin/sleep handled...
FromSent OnAttachments
den...@home.comJul 23, 1997 10:18 pm 
Jason ThorpeJul 23, 1997 11:09 pm 
Tim LiddelowJul 23, 1997 11:41 pm 
Jordan K. HubbardJul 24, 1997 2:06 am 
Jordan K. HubbardJul 24, 1997 2:11 am 
Bruce EvansJul 24, 1997 5:25 am 
Jason ThorpeJul 24, 1997 9:43 am 
Tim LiddelowJul 24, 1997 5:00 pm 
Sergei S. LaskavyJul 25, 1997 1:28 am 
Jason ThorpeJul 25, 1997 7:54 am 
FreeBSD Technical ReaderJul 26, 1997 12:28 pm 
FreeBSD Technical ReaderJul 26, 1997 12:29 pm 
Subject:Re: bin/4154: wish /bin/sleep handled fractions of a second.
From:FreeBSD Technical Reader (ker@acromail.ml.org)
Date:Jul 26, 1997 12:29:42 pm
List:org.freebsd.freebsd-bugs

The following reply was made to PR bin/4154; it has been noted by GNATS.

From: FreeBSD Technical Reader <ker@acromail.ml.org> To: den@home.com Cc: free@FreeBSD.ORG, GNATS Management <gna@FreeBSD.ORG>, free@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 den@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: