diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:06:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 17:06:04 +0000 |
commit | 2f0649f6fe411d7e07c8d56cf8ea56db53536da8 (patch) | |
tree | 778611fb52176dce1ad06c68e87b2cb348ca0f7b /usr/utils/sleep.c | |
parent | Initial commit. (diff) | |
download | klibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.tar.xz klibc-2f0649f6fe411d7e07c8d56cf8ea56db53536da8.zip |
Adding upstream version 2.0.13.upstream/2.0.13upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'usr/utils/sleep.c')
-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; +} |