bore

basic core utilities (PD)
git clone git://bvnf.space/bore.git
Log | Files | Refs | README

commit 954790d3acb7cd91aa1fe22ec19eb1c45caa3037
parent 573165850a9a9cd479bc6af922b3b73a7717a459
Author: phoebos <ben@bvnf.space>
Date:   Sat,  1 Oct 2022 22:18:31 +0100

sleep: add

Diffstat:
M.gitignore | 1+
MMakefile | 1+
MPROGRESS | 2+-
MTODO.posix | 2+-
Asleep.c | 20++++++++++++++++++++
5 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -10,6 +10,7 @@ nice pwd rm rmdir +sleep sort tee true diff --git a/Makefile b/Makefile @@ -13,6 +13,7 @@ BINS = \ pwd \ rm \ rmdir \ + sleep \ sort \ tee \ true \ diff --git a/PROGRESS b/PROGRESS @@ -33,7 +33,7 @@ [x] pwd [-LP] [ ] rm [ ] rmdir -[ ] sleep +[x] sleep [ ] sort [-r] [ ] split [ ] strings diff --git a/TODO.posix b/TODO.posix @@ -89,7 +89,7 @@ [.] rmdir [ ] sed [ ] sh -[ ] sleep +[x] sleep [.] sort [ ] split [ ] strings diff --git a/sleep.c b/sleep.c @@ -0,0 +1,20 @@ +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int +main(int argc, char **argv) { + if (argc != 2) { + fprintf(stderr, "usage: %s time\n", *argv); + return 1; + } + + errno = 0; + unsigned long t = strtoul(argv[1], NULL, 10); + if (errno || (signed long)t < 0) + return 1; + while (t > 0) + t = sleep(t); + return 0; +}