summaryrefslogtreecommitdiffstats
path: root/libc/unistd/alarm.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2010-07-08 17:19:07 -0700
committerDavid 'Digit' Turner <digit@google.com>2010-07-08 17:20:29 -0700
commitcb7e8c5ef3f5f60a848e469ed40610c8946fe7ac (patch)
tree57f834d14915d4a63edf62aa0026676064baba8f /libc/unistd/alarm.c
parentab8b54101eed0a4b92ebf8fa6994cd1b4f22d8f4 (diff)
downloadbionic-cb7e8c5ef3f5f60a848e469ed40610c8946fe7ac.zip
bionic-cb7e8c5ef3f5f60a848e469ed40610c8946fe7ac.tar.gz
bionic-cb7e8c5ef3f5f60a848e469ed40610c8946fe7ac.tar.bz2
libc: update alarm() implementation to return 0 on error.
This matches the GLibc behaviour, and allows alarm(0xFFFFFFFF) to return 0. Change-Id: I419aa71b27d6bb2015d15ba6b6112bf62eadcbb8
Diffstat (limited to 'libc/unistd/alarm.c')
-rw-r--r--libc/unistd/alarm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libc/unistd/alarm.c b/libc/unistd/alarm.c
index 01863a4..53edea9 100644
--- a/libc/unistd/alarm.c
+++ b/libc/unistd/alarm.c
@@ -51,7 +51,11 @@ alarm(secs)
itp->it_value.tv_sec = secs;
itp->it_value.tv_usec = 0;
if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
+#if 1 /* BIONIC: Same behaviour than GLibc for errors */
+ return 0;
+#else
return (-1);
+#endif
if (oitv.it_value.tv_usec)
oitv.it_value.tv_sec++;
return (oitv.it_value.tv_sec);