summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorlangqwu <[email protected]>2026-05-16 17:13:26 +0800
committerRbb666 <[email protected]>2026-05-26 14:01:02 +0800
commit208a09e074cf67879b31925ff5d25328781afc2b (patch)
tree87b7cba05e929ee7f5f31dd422c1da91d36c229a /components/libc
parent96f247170d122e6b13d3146e05f76423e8802607 (diff)
为posix_signal.c文件中的signal函数进行注释
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/posix/signal/posix_signal.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/components/libc/posix/signal/posix_signal.c b/components/libc/posix/signal/posix_signal.c
index 780d872faf..90850b5dd0 100644
--- a/components/libc/posix/signal/posix_signal.c
+++ b/components/libc/posix/signal/posix_signal.c
@@ -18,6 +18,24 @@
#define sig_valid(sig_no) (sig_no >= 0 && sig_no < RT_SIG_MAX)
+
+/**
+ * @brief Sets the disposition of a signal.
+ *
+ * @note The signal() function chooses one of three ways to handle the signal @p sig.
+ * The @p func argument specifies the action:
+ * - SIG_DFL: default handling.
+ * - SIG_IGN: ignore the signal.
+ * - function pointer: user-defined handler.
+ * This function is a simplified interface; the sigaction() function is recommended for portable applications.
+ *
+ * @param sig is the signal number (e.g., SIGINT, SIGTERM).
+ * @param func is the disposition or function to be called when the signal is received.
+ *
+ * @return Upon successful completion, signal() returns the previous disposition of the signal.
+ * On failure, SIG_ERR is returned and errno is set to indicate the error.
+ *
+ */
void (*signal(int sig, void (*func)(int))) (int)
{
return rt_signal_install(sig, func);