aboutsummaryrefslogtreecommitdiff
path: root/src/unistd/alarm.c
blob: 64d4887d1ab374f03572f54439c8edd9957489fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <unistd.h>
#include <sys/time.h>
#include "syscall.h"

unsigned alarm(unsigned seconds)
{
	struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 };
	setitimer(ITIMER_REAL, &it, &old);
	return old.it_value.tv_sec + !!old.it_value.tv_usec;
}


#ifdef TEST
int
main(void) {
	return 0;
}
#endif