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.

This commit is contained in:
Gregory Nutt 2018-09-02 14:19:30 -06:00
parent 316ffaddac
commit 9a42be5e9b
2 changed files with 12 additions and 2 deletions

View File

@ -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 * 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 * proxy task, then the ask is a child of the proxy, and not this
* task. waitpid() fails with ECHILD in either case. * 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 (ret < 0)
{ {
/* If the child thread does not exist, waitpid() will return /* If the child thread does not exist, waitpid() will return

View File

@ -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 * Here the scheduler will be unlocked while waitpid is waiting
* and if the application has not yet run, it will now be able to * and if the application has not yet run, it will now be able to
* do so. * 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 (ret < 0)
{ {
/* If the child thread does not exist, waitpid() will return /* If the child thread does not exist, waitpid() will return