[klibc] Allow greater precision with sleep
Jeff Bailey
jbailey at ubuntu.com
Thu Dec 8 18:36:43 PST 2005
With the ever growing struggle to keep boot times down, we needed the
ability to sleep for periods of less than one second. Everyone seems to
have nanosleep, so it doesn't look like there's a problem just using the
syscall.
Thanks to Scott James Remnant <scott at ubuntu.com> for this patch.
--- klibc-1.1.1~/utils/sleep.c 2005-09-06 21:49:34.000000000 +0100
+++ klibc-1.1.1/utils/sleep.c 2005-11-22 07:35:24.903935592 +0000
@@ -1,19 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
+#include <time.h>
+
int main(int argc, char *argv[])
{
- unsigned long s;
+ struct timespec ts;
char *p;
if (argc != 2)
goto err;
- s = strtoul(argv[1], &p, 10);
+ p = strtotimespec(argv[1], &ts);
if ( *p )
goto err;
- sleep(s);
+ nanosleep(&ts, NULL);
return 0;
* Canonical Ltd * Ubuntu Service and Support * +1 514 691 7221 *
Linux for Human Beings.
More information about the klibc
mailing list