This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 4d36a6d5601917a419c08af003041bf555369eb7 Author: Marco Casaroli <[email protected]> AuthorDate: Fri Oct 30 12:48:21 2026 +0100 nshlib: Give up the controlling terminal at the start of sh. The "sh" program (nsh_system_ctty()) makes its terminal the controlling terminal of each foreground command (TIOCSCTTY with the PID of the command) and gives it up after the command (TIOCNOTTY). So at the prompt there is no foreground process, and Ctrl-C and Ctrl-Z do not signal the shell. But sh can itself be the foreground process at its prompt: an "sh" typed at the NSH prompt is a foreground command of the first shell, and the parent of sh can make it the foreground process. Ctrl-C at the prompt of that sh sent SIGINT to it, and with CONFIG_SIG_DEFAULT this ended the shell. An interactive sh now gives up the controlling terminal at its start, as after each foreground command. "sh -c" does not change. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- nshlib/nsh_system.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nshlib/nsh_system.c b/nshlib/nsh_system.c index 902e8f5a5..ae1477909 100644 --- a/nshlib/nsh_system.c +++ b/nshlib/nsh_system.c @@ -28,6 +28,7 @@ #include <stdlib.h> #include <string.h> +#include <sys/ioctl.h> #include <assert.h> #include "nsh.h" @@ -44,6 +45,15 @@ static int nsh_system_(int argc, FAR char *argv[], int isctty) DEBUGASSERT(pstate != NULL); + /* At its prompt an interactive shell is not the foreground process, so + * that Ctrl-C and Ctrl-Z do not end or stop it. + */ + + if (isctty && argc < 2) + { + nsh_ioctl(&pstate->cn_vtbl, TIOCNOTTY, 0); + } + /* Execute the session */ ret = nsh_session(pstate, NSH_LOGIN_NONE, argc, argv);
