From 8f8b5310d2c3fe8782377bd66b65ed14dc6511a4 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 1 Mar 2010 11:30:40 -0800 Subject: Fix pthread_sigmask() to return correct error values. Before that, it returned -1 on error and set errno (not Posix) After the patch, it returns the error code and leaves errno untouched. --- libc/bionic/pthread.c | 12 +++++++++++- libc/docs/CHANGES.TXT | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'libc') diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c index 8171aac..c1a6a8a 100644 --- a/libc/bionic/pthread.c +++ b/libc/bionic/pthread.c @@ -1688,7 +1688,17 @@ extern int __rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t); int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) { - return __rt_sigprocmask(how, set, oset, _NSIG / 8); + /* pthread_sigmask must return the error code, but the syscall + * will set errno instead and return 0/-1 + */ + int ret, old_errno = errno; + + ret = __rt_sigprocmask(how, set, oset, _NSIG / 8); + if (ret < 0) + ret = errno; + + errno = old_errno; + return ret; } diff --git a/libc/docs/CHANGES.TXT b/libc/docs/CHANGES.TXT index e818df3..47289f6 100644 --- a/libc/docs/CHANGES.TXT +++ b/libc/docs/CHANGES.TXT @@ -64,6 +64,10 @@ Differences between current and Android 2.1: in /etc/resolv.conf. (resolv.conf is already ignored, so the latter is a no-op for actual functionality.) +- fix pthread_sigmask() to properly return an error code without touching + errno. Previous implementation returned -1 on error, setting errno, which + is not Posix compliant. + ------------------------------------------------------------------------------- Differences between Android 2.1 and 2.0.1: -- cgit v1.1