move sleep to bonsai coreutils
This commit is contained in:
1
Retired/sleep/Makefile
Normal file
1
Retired/sleep/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
sleep: sleep.c
|
||||
31
Retired/sleep/sleep.1
Normal file
31
Retired/sleep/sleep.1
Normal 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
25
Retired/sleep/sleep.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user