From a9cfba95a43c120745f8a69c6808f7e48a7d7ab6 Mon Sep 17 00:00:00 2001 From: xiahao Date: Fri, 10 Jan 2025 07:41:42 +0000 Subject: [PATCH] signal: fix sigaction function bug According to the standard description, the second parameter of the sigaction function can be null,and modifying the signal's testsuites bug Signed-off-by: xiahao --- src/libc/litelibc/src/signal/sigaction.c | 2 +- .../conformance/interfaces/sigaction/sigaction_test.c | 2 ++ testsuites/posixtestsuite/conformance/interfaces/sigpause/3-1.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libc/litelibc/src/signal/sigaction.c b/src/libc/litelibc/src/signal/sigaction.c index f7bb4035..45fb9c80 100644 --- a/src/libc/litelibc/src/signal/sigaction.c +++ b/src/libc/litelibc/src/signal/sigaction.c @@ -29,7 +29,7 @@ int __sigaction(int signum, const struct sigaction *__restrict act, struct sigac return -1; } - if (act->sa_flags == SA_SIGINFO) { + if (act&& (act->sa_flags == SA_SIGINFO)) { errno = ENOTSUP; return -1; } diff --git a/testsuites/posixtestsuite/conformance/interfaces/sigaction/sigaction_test.c b/testsuites/posixtestsuite/conformance/interfaces/sigaction/sigaction_test.c index 3ba80abc..697e388a 100644 --- a/testsuites/posixtestsuite/conformance/interfaces/sigaction/sigaction_test.c +++ b/testsuites/posixtestsuite/conformance/interfaces/sigaction/sigaction_test.c @@ -73,6 +73,8 @@ int TEST_sigaction_1(void) void *TEST_sigaction_pthread_1() { struct sigaction act; + sigemptyset(&act.sa_mask); + act.sa_handler = TEST_sigaction_Handler1; g_signo = SIGABRT; diff --git a/testsuites/posixtestsuite/conformance/interfaces/sigpause/3-1.c b/testsuites/posixtestsuite/conformance/interfaces/sigpause/3-1.c index e4e0cb1e..56d70dfb 100644 --- a/testsuites/posixtestsuite/conformance/interfaces/sigpause/3-1.c +++ b/testsuites/posixtestsuite/conformance/interfaces/sigpause/3-1.c @@ -71,6 +71,7 @@ int sigpause_3_1() { pthread_t new_th; + sem = INTHREAD; if(pthread_create(&new_th, NULL, a_thread_func, NULL) != 0) { perror("Error creating thread\n"); @@ -85,7 +86,6 @@ int sigpause_3_1() return PTS_UNRESOLVED; } - sem = INTHREAD; while (sem == INTHREAD) sleep(1); -- Gitee