This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit fbd5bc133bee74afb872781467a2c3f69e496cac Author: Marco Casaroli <[email protected]> AuthorDate: Tue Oct 6 18:34:40 2026 +0200 examples/nxflat: Fix the checks of the signal test. The handler set sigusr2_rcvd for SIGUSR1 and sigusr1_rcvd for SIGUSR2, so the first check failed even when the signal arrived. The last check removed the handler, sent SIGUSR2 and then required that the handler ran. Set the flag of the signal that arrived, and make the last check require that the removed handler does not run. Also name SIGUSR2, not SIGUSR1, in the messages of that step. The test still fails before apache/nuttx#20468: getpid() in a module that exec() started returns the pid of its caller, so kill(getpid(), SIGUSR1) signals examples/nxflat instead of the module. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- examples/nxflat/tests/signal/signal.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/examples/nxflat/tests/signal/signal.c b/examples/nxflat/tests/signal/signal.c index 63ee50767..745efa78c 100644 --- a/examples/nxflat/tests/signal/signal.c +++ b/examples/nxflat/tests/signal/signal.c @@ -79,12 +79,12 @@ void siguser_action(int signo, siginfo_t *siginfo, void *arg) if (signo == SIGUSR1) { printf(" SIGUSR1 received\n"); - sigusr2_rcvd = 1; + sigusr1_rcvd = 1; } else if (signo == SIGUSR2) { printf(" SIGUSR2 received\n"); - sigusr1_rcvd = 2; + sigusr2_rcvd = 1; } else { @@ -206,22 +206,20 @@ int main(int argc, char **argv) sigusr2_rcvd = 0; - /* Remove the siguser_action handler and replace the SIGUSR2 - * handler with sigusr2_sighandler. - */ + /* Remove the siguser_action handler and restore the old SIGUSR2 action */ printf("Resetting SIGUSR2 signal handler from pid=%d\n", mypid); status = sigaction(SIGUSR2, &oact2, &act); if (status != 0) { - fprintf(stderr, "Failed to install SIGUSR1 handler, errno=%d\n", + fprintf(stderr, "Failed to install SIGUSR2 handler, errno=%d\n", errno); exit(2); } - printf("Old SIGUSR1 sighandler at %p\n", act.sa_handler); - printf("New SIGUSR1 sighandler at %p\n", oact1.sa_handler); + printf("Old SIGUSR2 sighandler at %p\n", act.sa_handler); + printf("New SIGUSR2 sighandler at %p\n", oact2.sa_handler); /* Verify that the handler that was removed was siguser_action */ @@ -248,15 +246,14 @@ int main(int argc, char **argv) usleep(SHORT_DELAY); printf("SIGUSR2 killed from pid=%d\n", mypid); - /* Verify that SIGUSR2 was received */ + /* Verify that the removed handler did not run */ - if (sigusr2_rcvd == 0) + if (sigusr2_rcvd != 0) { - fprintf(stderr, "SIGUSR2 not received\n"); + fprintf(stderr, "SIGUSR2 received by a removed handler\n"); exit(10); } - sigusr2_rcvd = 0; - + printf("Signal test PASSED\n"); return 0; }
