1
0

move sleep to bonsai coreutils

This commit is contained in:
dtb
2024-03-21 21:12:01 -06:00
parent 06a41eb732
commit df5ecb7e2f
3 changed files with 0 additions and 0 deletions

1
Retired/sleep/Makefile Normal file
View File

@@ -0,0 +1 @@
sleep: sleep.c

31
Retired/sleep/sleep.1 Normal file
View File

@@ -0,0 +1,31 @@
.TH SLEEP 1
.SH NAME
sleep \(en wait a moment
.SH SYNOPSIS
sleep
.RB [ seconds ]
.SH DESCRIPTION
Sleep waits the given amount of seconds before exiting.
.SH EXIT STATUS
Sleep exits with a status indicating how much time is left for the program to sleep;
in practice, this is always 0.
.SH BUGS
User may still be tired after invoking sleep.
.SH COPYRIGHT
Public domain.
.SH SEE ALSO
sleep(3)

25
Retired/sleep/sleep.c Normal file
View File

@@ -0,0 +1,25 @@
#include <errno.h> /* errno */
#include <stdio.h> /* fprintf(3), stderr */
#include <stdlib.h> /* strtol(3) */
#include <sysexits.h> /* EX_USAGE */
#include <unistd.h> /* sleep(3) */
static char *program_name = "sleep";
int main(int argc, char **argv){
int s;
extern int errno;
if(argc != 2){
usage: fprintf(stderr, "Usage: %s [seconds]\n",
argv[0] == NULL ? program_name : argv[0]);
return EX_USAGE;
}
errno = 0;
s = strtol(argv[1], &argv[1], 10);
if(*argv[1] != '\0' || errno != 0)
goto usage;
while(s > 0)
s = sleep(s);
return s;
}