apps/nshlib: Add control-C support for terminating built-in and exec'ed file tasks.

This commit is contained in:
ligd 2018-08-26 07:48:38 -06:00 committed by Gregory Nutt
parent 0d6c9b8fbd
commit d36e1c87fe
2 changed files with 20 additions and 0 deletions

View File

@ -47,6 +47,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_SCHED_WAITPID
# include <sys/ioctl.h>
# include <sys/wait.h>
#endif
@ -134,6 +135,13 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
{
int rc = 0;
/* Setup up to receive SIGKILL if control-C entered. The return
* value is ignored because this console device may not support
* SIGKILL.
*/
(void)ioctl(stdout->fs_fd, TIOCSCTTY, ret);
/* Wait for the application to exit. We did lock the scheduler
* above, but that does not guarantee that the application did not
* already run to completion in the case where I/O was redirected.
@ -187,6 +195,8 @@ int nsh_builtin(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
* the most recently executed task.
*/
}
(void)ioctl(stdout->fs_fd, TIOCSCTTY, -1);
}
# ifndef CONFIG_NSH_DISABLEBG
else

View File

@ -40,6 +40,7 @@
#include <nuttx/config.h>
#ifdef CONFIG_SCHED_WAITPID
# include <sys/ioctl.h>
# include <sys/wait.h>
#endif
@ -171,6 +172,13 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
{
int rc = 0;
/* Setup up to receive SIGKILL if control-C entered. The return
* value is ignored because this console device may not support
* SIGKILL.
*/
(void)ioctl(stdout->fs_fd, TIOCSCTTY, pid);
/* Wait for the application to exit. We did lock the scheduler
* above, but that does not guarantee that the application did not
* already run to completion in the case where I/O was redirected.
@ -219,6 +227,8 @@ int nsh_fileapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
* the most recently executed task.
*/
}
(void)ioctl(stdout->fs_fd, TIOCSCTTY, -1);
}
# ifndef CONFIG_NSH_DISABLEBG
else