master xplshn/aruu / cmd / posix / sleep.c
 1/* See LICENSE file for copyright and license details. */
 2
 3#include <unistd.h>
 4
 5#include "util.h"
 6
 7static void
 8usage(void)
 9{
10  eprintf("usage: %s num\n", argv0);
11}
12
13// ?man sleep: delay for a duration
14// ?man arguments: num
15// ?man pause execution for a specified amount of time
16int
17main(int argc, char *argv[])
18{
19  unsigned seconds;
20
21  ARGBEGIN
22  {
23    default:
24      usage();
25  }
26  ARGEND
27
28  if (argc != 1)
29    usage();
30
31  seconds = estrtonum(argv[0], 0, UINT_MAX);
32  while ((seconds = sleep(seconds)) > 0)
33    ;
34
35  return 0;
36}