You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/07/12 13:27:14 UTC
[nuttx] 02/02: signal: SIGKILL or SIGSTOP cannot be caught
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ffa084f3d27f8c636ca9f6a8e4b94c36bf2487f9
Author: fangxinyong <fa...@xiaomi.com>
AuthorDate: Sat Jun 24 18:19:25 2023 +0800
signal: SIGKILL or SIGSTOP cannot be caught
pass ltp signal test cases, for posix spec, SIGKILL and SIGSTOP cannot be caught.
https://pubs.opengroup.org/onlinepubs/9699919799/functions/signal.html
https://pubs.opengroup.org/onlinepubs/007904875/functions/sigset.html
Signed-off-by: fangxinyong <fa...@xiaomi.com>
---
include/signal.h | 6 ++++--
libs/libc/signal/sig_set.c | 2 +-
libs/libc/signal/sig_signal.c | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/signal.h b/include/signal.h
index fa00c94119..7318a334d3 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -39,7 +39,6 @@
#define MIN_SIGNO 1 /* Lowest valid signal number */
#define MAX_SIGNO 63 /* Highest valid signal number */
-#define GOOD_SIGNO(s) ((((unsigned)(s)) <= MAX_SIGNO))
/* Definitions for "standard" signals */
@@ -236,7 +235,10 @@
# define SIG_HOLD ((_sa_handler_t)1) /* Used only with sigset() */
#endif
-#define tkill(tid, signo) tgkill((pid_t)-1, tid, signo)
+#define GOOD_SIGNO(s) (((unsigned)(s)) <= MAX_SIGNO)
+#define UNCAUGHT_SIGNO(s) ((s) == SIGKILL || (s) == SIGSTOP)
+
+#define tkill(tid, signo) tgkill((pid_t)-1, tid, signo)
/****************************************************************************
* Public Types
diff --git a/libs/libc/signal/sig_set.c b/libs/libc/signal/sig_set.c
index 24b0fc34ee..3b78f6bc1f 100644
--- a/libs/libc/signal/sig_set.c
+++ b/libs/libc/signal/sig_set.c
@@ -101,7 +101,7 @@ _sa_handler_t sigset(int signo, _sa_handler_t func)
sigset_t set;
int ret = -EINVAL;
- if (signo == SIGKILL || signo == SIGSTOP || !GOOD_SIGNO(signo))
+ if (!GOOD_SIGNO(signo) || UNCAUGHT_SIGNO(signo))
{
goto err;
}
diff --git a/libs/libc/signal/sig_signal.c b/libs/libc/signal/sig_signal.c
index 5dbcf9faae..d16191042b 100644
--- a/libs/libc/signal/sig_signal.c
+++ b/libs/libc/signal/sig_signal.c
@@ -62,7 +62,7 @@ _sa_handler_t signal(int signo, _sa_handler_t func)
struct sigaction oact;
int ret = -EINVAL;
- if (!GOOD_SIGNO(signo))
+ if (!GOOD_SIGNO(signo) || UNCAUGHT_SIGNO(signo))
{
goto err;
}