From 7f424c3e8ddaa0a6a828175b8e4205c1cc0a2a8a Mon Sep 17 00:00:00 2001 From: chao an Date: Fri, 7 Feb 2025 22:49:17 +0800 Subject: [PATCH] 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 --- 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);