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 8USE_SLEEP(NEWTOY(sleep, "<1", TOYFLAG_BIN)) 9 10config 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 24void sleep_main(void) 25{ 26 struct timespec ts; 27 28 xparsetimespec(*toys.optargs, &ts); 29 toys.exitval = !!nanosleep(&ts, NULL); 30} 31