Home | History | Annotate | Download | only in posix
      1 /* sleep.c - Wait for a number of seconds.
      2  *
      3  * Copyright 2007 Rob Landley <rob (at) landley.net>
      4  * Copyright 2012 Georgi Chorbadzhiyski <georgi (at) 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 
     24 void sleep_main(void)
     25 {
     26   struct timespec tv;
     27 
     28   tv.tv_sec = xparsetime(*toys.optargs, 9, &tv.tv_nsec);
     29   toys.exitval = !!nanosleep(&tv, NULL);
     30 }
     31