1
0

more cleaning

This commit is contained in:
dtb
2022-09-18 00:34:03 -04:00
parent fbdaf55d1c
commit 05c3fad56e
8 changed files with 0 additions and 0 deletions

25
sleep/sleep.c Normal file
View File

@@ -0,0 +1,25 @@
#include <ctype.h> /* isdigit(3) */
#include <stdlib.h> /* atoi(3) */
#include <sysexits.h> /* EX_USAGE */
#include <unistd.h> /* sleep(3) */
#include "libio.h"
static char *program_name = "sleep";
int main(int argc, char **argv){
int s;
if(argc != 2){
usage: write(2, "Usage: ", 7);
fdprint(2, argv[0] == NULL ? program_name : argv[0]);
write(2, " [seconds]\n", 11);
return EX_USAGE;
}
s = parse_uint(argv[1]);
while(isdigit(*argv[1]))
++argv[1];
if(*argv[1] != '\0')
goto usage;
while(s > 0)
s = sleep(s);
return s;
}