Skip to content

testing/ostest: Catch the SIGUSR1 that wakes up the mqueue receiver. - #3947

Merged
acassis merged 2 commits into
apache:masterfrom
casaroli:ostest-mqueue-sigusr1-up
Oct 31, 2026
Merged

acassis merged 2 commits into
apache:masterfrom
casaroli:ostest-mqueue-sigusr1-up

Conversation

@casaroli

@casaroli casaroli commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

mqueue_test wakes up its receiver thread with pthread_kill(receiver, SIGUSR1) and expects only that mq_receive() is interrupted. Nothing catches the signal. With CONFIG_SIG_SIGUSR1_ACTION, SIGUSR1 has its POSIX default action, which ends the whole process, so ostest ends in mqueue_test ("mqueue_test: Killing receiver", exit status 256).

The second commit installs a handler that does nothing for SIGUSR1 during the test (with CONFIG_ENABLE_ALL_SIGNALS, which sigaction() needs) and restores the old action at the end. The first commit fixes an nxstyle error in the same file (checkpatch checks the whole file).

This happens on master in the flat build. In a kernel build the receiver does not get the signal on master, because of a kernel bug that apache/nuttx#21216 (sched/signal: Release the signals pending for a thread when it exits.) fixes; with that fix, the kernel build also ends in mqueue_test. Merge order: this PR first, then the NuttX PR, which has a depends-on line for this PR.

Impact

ostest only. Without CONFIG_SIG_SIGUSR1_ACTION the test behaves as before. Not a breaking change.

Testing

ostest exit status on QEMU with HVF, CONFIG_SIG_SIGUSR1_ACTION, CONFIG_SCHED_CHILD_STATUS and CONFIG_CANCELLATION_POINTS:

NuttX apps qemu-armv8a:knsh qemu-armv8a:nsh qemu-armv8a:nsh + CONFIG_SIG_DEFAULT
master master no end: assertion in signest_test (the kernel bug) 0 256: ends in mqueue_test
master this PR 0 0 0
the NuttX PR master 256: ends in mqueue_test 0 256: ends in mqueue_test
the NuttX PR this PR 0 0 0

NuttX master is 23f5a4f06df (7505b874722, #21072, does not build for arm64: lib_libvsprintf.c, -Werror=shadow; fixed by #21210); rows 2 and 3 are from the earlier NuttX base 3122150b1f1. CONFIG_SIG_DEFAULT gives SIGUSR1 its default action in the flat build; the knsh defconfig has it.

Build: qemu-armv8a:nsh with CONFIG_ENABLE_PARTIAL_SIGNALS (no sigaction()) and with CONFIG_SIG_SIGUSR1_ACTION; qemu-armv8a:knsh; rv-virt:pnsh64; mps2-an500:knsh. All OK, no warning in mqueue.c.

tools/checkpatch.sh -c -u -m -g passes.

Align the printf() of a corrupt message in receiver_thread() and its
arguments.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
mqueue_test wakes up its receiver thread with pthread_kill(SIGUSR1) and
expects only that mq_receive() is interrupted.  Nothing caught the
signal.  With CONFIG_SIG_SIGUSR1_ACTION, SIGUSR1 has its POSIX default
action, and the default action ends the whole process: ostest stopped in
mqueue_test.

Install a handler that does nothing for SIGUSR1 during the test, and
restore the old action at the end.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
@acassis
acassis merged commit fc8723f into apache:master Oct 31, 2026
49 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants