about summary refs log tree commit diff
path: root/src/unistd
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-05-24 12:21:34 -0400
committerRich Felker <dalias@aerifal.cx>2012-05-24 12:21:34 -0400
commite241896cd5ebe5d6b8e725fe4ac7a8d9c0980319 (patch)
treef5fcc368a075a4cd34ec817bbb7e421ce271a354 /src/unistd
parentc37afdfdf393261e18364aed52571d0a5b011044 (diff)
downloadmusl-e241896cd5ebe5d6b8e725fe4ac7a8d9c0980319.tar.gz
musl-e241896cd5ebe5d6b8e725fe4ac7a8d9c0980319.tar.xz
musl-e241896cd5ebe5d6b8e725fe4ac7a8d9c0980319.zip
avoid deprecated (by linux) alarm syscall; use setitimer instead
Diffstat (limited to 'src/unistd')
-rw-r--r--src/unistd/alarm.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/unistd/alarm.c b/src/unistd/alarm.c
index 244af1c0..2e3263ac 100644
--- a/src/unistd/alarm.c
+++ b/src/unistd/alarm.c
@@ -1,7 +1,10 @@
 #include <unistd.h>
+#include <sys/time.h>
 #include "syscall.h"
 
 unsigned alarm(unsigned seconds)
 {
-	return syscall(SYS_alarm, seconds);
+	struct itimerval it = { .it_value.tv_sec = seconds };
+	__syscall(SYS_setitimer, ITIMER_REAL, &it, &it);
+	return it.it_value.tv_sec + !!it.it_value.tv_usec;
 }