diff --git a/libc/Android.mk b/libc/Android.mk index 8a8936f53..c801afb88 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -199,7 +199,6 @@ libc_common_src_files := \ bionic/ptsname_r.c \ bionic/pututline.c \ bionic/pwrite.c \ - bionic/raise.c \ bionic/realpath.c \ bionic/reboot.c \ bionic/recv.c \ @@ -282,6 +281,7 @@ libc_bionic_src_files := \ bionic/__memcpy_chk.cpp \ bionic/__memmove_chk.cpp \ bionic/__memset_chk.cpp \ + bionic/raise.cpp \ bionic/__set_errno.cpp \ bionic/setlocale.cpp \ bionic/__strcat_chk.cpp \ diff --git a/libc/bionic/raise.c b/libc/bionic/raise.cpp similarity index 90% rename from libc/bionic/raise.c rename to libc/bionic/raise.cpp index 7b03a7ab9..f69d90b60 100644 --- a/libc/bionic/raise.c +++ b/libc/bionic/raise.cpp @@ -25,10 +25,14 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include -#include -int raise(int signum) -{ - return kill(gettid(), signum); +#include + +int raise(int sig) { + int rc = pthread_kill(pthread_self(), sig); + if (rc != 0) { + errno = rc; + return -1; + } + return 0; } diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp index a54f14d31..fcfcb184b 100644 --- a/tests/signal_test.cpp +++ b/tests/signal_test.cpp @@ -95,3 +95,9 @@ TEST(signal, sigemptyset_invalid) { TEST(signal, sigfillset_invalid) { TestSigSet1(sigfillset); } + +TEST(signal, raise_invalid) { + errno = 0; + ASSERT_EQ(-1, raise(-1)); + ASSERT_EQ(EINVAL, errno); +}