From 4f9eae68be7473959ece8d2481aad896e52985b8 Mon Sep 17 00:00:00 2001 From: Charlie Tsai Date: Tue, 7 Jul 2026 02:13:19 +0800 Subject: [PATCH] preempt_sched: use sa_sigaction for SA_SIGINFO According to sigaction(2), when SA_SIGINFO is specified in sa_flags, the signal handler should be sa_sigaction instead of sa_handler. timer_handler() uses the three-argument signal handler form, but the current code registers it through sa_handler by casting it to a one-argument handler type. Use sa_sigaction to match the documented API and avoid casting between incompatible function pointer types. Reference: https://man7.org/linux/man-pages/man2/sigaction.2.html --- preempt_sched/task_sched.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/preempt_sched/task_sched.c b/preempt_sched/task_sched.c index 79c525d..1fdc013 100644 --- a/preempt_sched/task_sched.c +++ b/preempt_sched/task_sched.c @@ -166,7 +166,7 @@ static void task_add(task_callback_t *func, void *param) preempt_enable(); } -static void timer_handler(int signo, siginfo_t *info, ucontext_t *ctx) +static void timer_handler(int signo, siginfo_t *info, void *ctx) { if (preempt_count) /* once preemption is disabled */ return; @@ -180,7 +180,7 @@ static void timer_handler(int signo, siginfo_t *info, ucontext_t *ctx) static void timer_init(void) { struct sigaction sa = { - .sa_handler = (void (*)(int)) timer_handler, + .sa_sigaction = timer_handler, .sa_flags = SA_SIGINFO, }; sigfillset(&sa.sa_mask);