diff options
Diffstat (limited to '')
-rw-r--r-- | usr/utils/sleep.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/usr/utils/sleep.c b/usr/utils/sleep.c new file mode 100644 index 0000000..991cdbe --- /dev/null +++ b/usr/utils/sleep.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> +#include <errno.h> + +int main(int argc, char *argv[]) +{ + struct timespec ts; + char *p; + + if (argc != 2) + goto err; + + p = strtotimespec(argv[1], &ts); + if (*p) + goto err; + + while (nanosleep(&ts, &ts) == -1 && errno == EINTR) + ; + + return 0; + +err: + fprintf(stderr, "Usage: %s seconds[.fraction]\n", argv[0]); + return 1; +} |