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 a3dd498f9f576057b00956e08dcfc2c0a2090e9f Author: Marco Casaroli <[email protected]> AuthorDate: Sun Oct 18 12:58:53 2026 +0200 examples/usrsocktest: Install a handler for SIGUSR1 in the wake test. The wake test sends SIGUSR1 to its threads to break them out of blocking socket calls, but it installed no handler for SIGUSR1. An ignored signal need not interrupt the calls, and with CONFIG_SIG_DISCARD_IGNORED it does not. Install an empty handler before the threads start. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- .../usrsocktest/usrsocktest_wake_with_signal.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/usrsocktest/usrsocktest_wake_with_signal.c b/examples/usrsocktest/usrsocktest_wake_with_signal.c index 068e054e0..d8b091e68 100644 --- a/examples/usrsocktest/usrsocktest_wake_with_signal.c +++ b/examples/usrsocktest/usrsocktest_wake_with_signal.c @@ -24,6 +24,8 @@ * Included Files ****************************************************************************/ +#include <signal.h> +#include <string.h> #include <sys/socket.h> #include <assert.h> #include <netinet/in.h> @@ -575,6 +577,12 @@ static FAR void *usrsock_blocking_poll_thread(FAR void *param) return NULL; } +#ifdef CONFIG_ENABLE_ALL_SIGNALS +static void wake_signal(int signo) +{ +} +#endif + static void do_wake_test(enum e_test_type type, int flags) { int ret; @@ -582,6 +590,9 @@ static void do_wake_test(enum e_test_type type, int flags) int tidx; bool test_abort = !!(flags & TEST_FLAG_DAEMON_ABORT); bool test_hang = !!(flags & TEST_FLAG_PAUSE_USRSOCK_HANDLING); +#ifdef CONFIG_ENABLE_ALL_SIGNALS + struct sigaction sa; +#endif /* Start test daemon. */ @@ -589,6 +600,17 @@ static void do_wake_test(enum e_test_type type, int flags) usrsocktest_daemon_start(&usrsocktest_daemon_config)); TEST_ASSERT_EQUAL(0, usrsocktest_daemon_get_num_active_sockets()); +#ifdef CONFIG_ENABLE_ALL_SIGNALS + /* The test wakes the threads with SIGUSR1: install a handler, because an + * ignored signal need not interrupt a blocking call. + */ + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = wake_signal; + sigemptyset(&sa.sa_mask); + sigaction(SIGUSR1, &sa, NULL); +#endif + /* Launch worker threads. */ test_type = type;
