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


The following commit(s) were added to refs/heads/master by this push:
     new 7f424c3e8 nshlib/builtin: check background task before restore the 
signal
7f424c3e8 is described below

commit 7f424c3e8ddaa0a6a828175b8e4205c1cc0a2a8a
Author: chao an <anchao.arc...@bytedance.com>
AuthorDate: Fri Feb 7 22:49:17 2025 +0800

    nshlib/builtin: check background task before restore the signal
    
    fix crash if:
    CONFIG_SCHED_WAITPID=n
    CONFIG_SCHED_CHILD_STATUS=y
    
    The old signal will be restored only when sigaction is saved to avoid 
invaild access.
    
    Signed-off-by: chao an <anchao.arc...@bytedance.com>
---
 nshlib/nsh_builtin.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/nshlib/nsh_builtin.c b/nshlib/nsh_builtin.c
index 6ff8f99a6..196220f41 100644
--- a/nshlib/nsh_builtin.c
+++ b/nshlib/nsh_builtin.c
@@ -234,7 +234,13 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const 
char *cmd,
 
           /* Restore the old actions */
 
-          sigaction(SIGCHLD, &old, NULL);
+#  ifndef CONFIG_SCHED_WAITPID
+          if (vtbl->np.np_bg == true)
+#  endif
+            {
+              sigaction(SIGCHLD, &old, NULL);
+            }
+
 #  endif
           struct sched_param sched;
           sched_getparam(ret, &sched);

Reply via email to