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 81b22625ad62e4dc5a8b0b6a50535b7ce2c1d767
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Oct 18 12:58:35 2026 +0200

    netutils/ftpc: Install a handler for CONFIG_FTP_SIGNAL.
    
    ftpc_timeout() sends CONFIG_FTP_SIGNAL to break the session task out of
    a blocking call, but nothing installed a handler for it.  An ignored
    signal need not interrupt the call, and with CONFIG_SIG_DISCARD_IGNORED
    it does not.
    
    Install an empty handler in ftpc_connect().
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 netutils/ftpc/ftpc_connect.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/netutils/ftpc/ftpc_connect.c b/netutils/ftpc/ftpc_connect.c
index f28c40b61..06f3c03be 100644
--- a/netutils/ftpc/ftpc_connect.c
+++ b/netutils/ftpc/ftpc_connect.c
@@ -28,6 +28,7 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include <signal.h>
 #include <string.h>
 #include <errno.h>
 #include <nuttx/debug.h>
@@ -38,6 +39,24 @@
 
 #include "ftpc_internal.h"
 
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+/****************************************************************************
+ * Name: ftpc_wakeup
+ *
+ * Description:
+ *   An empty handler for CONFIG_FTP_SIGNAL.
+ *
+ ****************************************************************************/
+
+static void ftpc_wakeup(int signo)
+{
+}
+#endif
+
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -53,6 +72,9 @@
 SESSION ftpc_connect(FAR union ftpc_sockaddr_u *server)
 {
   FAR struct ftpc_session_s *session;
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+  struct sigaction sa;
+#endif
   int ret;
 
   /* Allocate a session structure */
@@ -75,6 +97,17 @@ SESSION ftpc_connect(FAR union ftpc_sockaddr_u *server)
   session->conntimeo   = CONFIG_FTP_DEFTIMEO * CLOCKS_PER_SEC;
   session->pid         = getpid();
 
+  /* ftpc_timeout() wakes this task with CONFIG_FTP_SIGNAL: install a
+   * handler, because an ignored signal need not interrupt a blocking call.
+   */
+
+#ifdef CONFIG_ENABLE_ALL_SIGNALS
+  memset(&sa, 0, sizeof(sa));
+  sa.sa_handler = ftpc_wakeup;
+  sigemptyset(&sa.sa_mask);
+  sigaction(CONFIG_FTP_SIGNAL, &sa, NULL);
+#endif
+
   session->cmd.sd       = -1;
   session->data.sd      = -1;
   session->dacceptor.sd = -1;

Reply via email to