From 9a42be5e9b00c0594fbf5590ded17c4407670e6e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 2 Sep 2018 14:19:30 -0600 Subject: [PATCH] apps/nshlib: When using waitpid() to wait for a built-in application or a file application to exit. Add the WUNTRACED options to so the the waitpid() call will also be awakened if the waited-for task is stopped as well. --- nshlib/nsh_builtin.c | 7 ++++++- nshlib/nsh_fileapps.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/nshlib/nsh_builtin.c b/nshlib/nsh_builtin.c index 264979d04..c7a1768d9 100644 --- a/nshlib/nsh_builtin.c +++ b/nshlib/nsh_builtin.c @@ -153,9 +153,14 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, * even if task is still active: If the I/O was re-directed by a * proxy task, then the ask is a child of the proxy, and not this * task. waitpid() fails with ECHILD in either case. + * + * NOTE: WUNTRACED does nothing in the default case, but in the + * case the where CONFIG_SIG_SIGSTOP_ACTION=y, the built-in app + * may also be stopped. In that case WUNTRACED will force + * waitpid() to return with ECHILD. */ - ret = waitpid(ret, &rc, 0); + ret = waitpid(pid, &rc, WUNTRACED); if (ret < 0) { /* If the child thread does not exist, waitpid() will return diff --git a/nshlib/nsh_fileapps.c b/nshlib/nsh_fileapps.c index 4b1bcc3bd..adb99a5e6 100644 --- a/nshlib/nsh_fileapps.c +++ b/nshlib/nsh_fileapps.c @@ -185,9 +185,14 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, * Here the scheduler will be unlocked while waitpid is waiting * and if the application has not yet run, it will now be able to * do so. + * + * NOTE: WUNTRACED does nothing in the default case, but in the + * case the where CONFIG_SIG_SIGSTOP_ACTION=y, the file app + * may also be stopped. In that case WUNTRACED will force + * waitpid() to return with ECHILD. */ - ret = waitpid(pid, &rc, 0); + ret = waitpid(pid, &rc, WUNTRACED); if (ret < 0) { /* If the child thread does not exist, waitpid() will return