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.archer@bytedance.com>
This commit is contained in:
chao an 2025-02-07 22:49:17 +08:00 committed by Alan C. Assis
parent fb0c1e10de
commit 7f424c3e8d

View file

@ -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);