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 LENGTH 15 16 Wait before exiting. An optional suffix can be "m" (minutes), "h" (hours), 17 "d" (days), or "s" (seconds, the default). 18 19 20config SLEEP_FLOAT 21 bool 22 default y 23 depends on SLEEP && TOYBOX_FLOAT 24 help 25 Length can be a decimal fraction. 26*/ 27 28#include "toys.h" 29 30void sleep_main(void) 31{ 32 struct timespec tv; 33 34 tv.tv_sec = xparsetime(*toys.optargs, 1000000000, &tv.tv_nsec); 35 toys.exitval = !!nanosleep(&tv, NULL); 36} 37