1 /* sleep.c - Wait for a number of seconds. 2 * 3 * Copyright 2007 Rob Landley <rob@landley.net> 4 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org> 5 * 6 * See http://opengroup.org/onlinepubs/9699919799/utilities/sleep.html 7 8 USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN)) 9 10 config SLEEP 11 bool "sleep" 12 default y 13 help 14 usage: sleep DURATION... 15 16 Wait before exiting. 17 18 DURATION can be a decimal fraction. An optional suffix can be "m" 19 (minutes), "h" (hours), "d" (days), or "s" (seconds, the default). 20 */ 21 22 #include "toys.h" 23 sleep_main(void)24void sleep_main(void) 25 { 26 struct timespec ts; 27 char **args; 28 29 for (args = toys.optargs; !toys.exitval && *args; args++) { 30 xparsetimespec(*args, &ts); 31 toys.exitval = !!nanosleep(&ts, NULL); 32 } 33 } 34