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 62ccc756e4ffdb1a9081c60d7f68443df53dd0a0 Author: Marco Casaroli <[email protected]> AuthorDate: Sun Oct 18 12:58:35 2026 +0200 netutils/ntpclient: Install a handler for the wake-up signal. ntpc_stop() sends CONFIG_NETUTILS_NTPCLIENT_SIGWAKEUP to break the daemon out of a blocking call, but the daemon installed no handler for it. An ignored signal need not interrupt the call, and with CONFIG_SIG_DISCARD_IGNORED it does not. Install an empty handler when the daemon starts. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- netutils/ntpclient/ntpclient.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/netutils/ntpclient/ntpclient.c b/netutils/ntpclient/ntpclient.c index b75f8126a..08f26c515 100644 --- a/netutils/ntpclient/ntpclient.c +++ b/netutils/ntpclient/ntpclient.c @@ -35,6 +35,7 @@ #include <stdio.h> #include <stdlib.h> +#include <signal.h> #include <string.h> #include <time.h> #include <sched.h> @@ -1368,6 +1369,22 @@ sock_error: return ERROR; } +#ifdef CONFIG_ENABLE_ALL_SIGNALS +/**************************************************************************** + * Name: ntpc_wakeup + * + * Description: + * An empty handler for CONFIG_NETUTILS_NTPCLIENT_SIGWAKEUP. ntpc_stop() + * sends the signal to break the daemon out of a blocking call; an ignored + * signal need not interrupt it. + * + ****************************************************************************/ + +static void ntpc_wakeup(int signo) +{ +} +#endif + /**************************************************************************** * Name: ntpc_daemon * @@ -1382,6 +1399,9 @@ static int ntpc_daemon(int argc, FAR char **argv) { FAR struct ntp_sample_s *samples; FAR struct ntp_servers_s *srvs; +#ifdef CONFIG_ENABLE_ALL_SIGNALS + struct sigaction sa; +#endif int exitcode = EXIT_SUCCESS; int retries = 0; int retry_delay = 1; @@ -1406,6 +1426,15 @@ static int ntpc_daemon(int argc, FAR char **argv) return EXIT_FAILURE; } +#ifdef CONFIG_ENABLE_ALL_SIGNALS + /* ntpc_stop() wakes the daemon with a signal: install a handler */ + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = ntpc_wakeup; + sigemptyset(&sa.sa_mask); + sigaction(CONFIG_NETUTILS_NTPCLIENT_SIGWAKEUP, &sa, NULL); +#endif + /* Indicate that we have started */ g_ntpc_daemon.state = NTP_RUNNING;
