From a010cb1af1d1e49e6e4ae15f724de96a50bdeeb5 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 17 Dec 2021 22:03:10 +0800 Subject: [PATCH] serial: Make SIGINT and SIGTSTP work even without CONFIG_SERIAL_TERMIOS Signed-off-by: Xiang Xiao --- drivers/serial/Kconfig | 2 -- drivers/serial/serial.c | 6 +++--- include/nuttx/serial/serial.h | 7 ++++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index b63ca0ae18..0a2f7adb07 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -191,7 +191,6 @@ config TTY_FORCE_PANIC_CHAR config TTY_SIGINT bool "Support SIGINT" default n - depends on SERIAL_TERMIOS ---help--- Whether support Ctrl-c/x event. Enabled automatically for console devices. May be enabled for other serial devices using the ISIG bit @@ -235,7 +234,6 @@ config TTY_SIGINT_CHAR config TTY_SIGTSTP bool "Support SIGTSTP" default n - depends on SERIAL_TERMIOS ---help--- Whether support Ctrl-z event. Enabled automatically for console devices. May be enabled for other serial devices using the ISIG bit diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 26792547a9..ab7d73f865 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -1603,13 +1603,13 @@ errout: int uart_register(FAR const char *path, FAR uart_dev_t *dev) { -#ifdef CONFIG_SERIAL_TERMIOS -# if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP) +#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP) /* Initialize of the task that will receive SIGINT signals. */ dev->pid = (pid_t)-1; -# endif +#endif +#ifdef CONFIG_SERIAL_TERMIOS /* If this UART is a serial console */ if (dev->isconsole) diff --git a/include/nuttx/serial/serial.h b/include/nuttx/serial/serial.h index 5d2435df4c..6645da5183 100644 --- a/include/nuttx/serial/serial.h +++ b/include/nuttx/serial/serial.h @@ -280,15 +280,16 @@ struct uart_dev_s #endif bool isconsole; /* true: This is the serial console */ +#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP) + pid_t pid; /* Thread PID to receive signals (-1 if none) */ +#endif + #ifdef CONFIG_SERIAL_TERMIOS /* Terminal control flags */ tcflag_t tc_iflag; /* Input modes */ tcflag_t tc_oflag; /* Output modes */ tcflag_t tc_lflag; /* Local modes */ -#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGTSTP) - pid_t pid; /* Thread PID to receive signals (-1 if none) */ -#endif #endif /* Semaphores */