File: sleep.c

package info (click to toggle)
klibc 2.0.6-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,376 kB
  • sloc: ansic: 48,424; asm: 2,539; perl: 789; makefile: 231; sh: 160
file content (26 lines) | stat: -rw-r--r-- 378 bytes parent folder | download | duplicates (8)
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;
}