apps/nshlib: Add control-C support for terminating built-in and exec'ed file tasks.
This commit is contained in:
parent
0d6c9b8fbd
commit
d36e1c87fe
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user