summaryrefslogtreecommitdiffstats
path: root/usr/utils/sleep.c
blob: 991cdbe3b99ac21f53099c63ec7448d3cb1081ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>

int main(int argc, char *argv[])
{
	struct timespec ts;
	char *p;

	if (argc != 2)
		goto err;

	p = strtotimespec(argv[1], &ts);
	if (*p)
		goto err;

	while (nanosleep(&ts, &ts) == -1 && errno == EINTR)
		;

	return 0;

err:
	fprintf(stderr, "Usage: %s seconds[.fraction]\n", argv[0]);
	return 1;
}