mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
drivers/serial: Integrate new Ctrl-C logic with the ISIG flag in the termios c_lflag. Fix several compiler errors resulting from recently flurry of renaming.
This commit is contained in:
+22
-20
@@ -19,26 +19,6 @@ config SERIAL_CONSOLE
|
||||
bool
|
||||
default n
|
||||
|
||||
config TTY_SIGKILL
|
||||
bool "Support SIGKILL"
|
||||
default n
|
||||
select SIG_DEFAULT
|
||||
depends on !DISABLE_SIGNALS
|
||||
---help---
|
||||
Whether support Ctrl-c/x event
|
||||
|
||||
config TTY_SIGKILL_CHAR
|
||||
int "Serial parse SIGKILL characters"
|
||||
default 3 if SERIAL_CONSOLE
|
||||
default 4 if !SERIAL_CONSOLE
|
||||
depends on SIG_SIGKILL
|
||||
---help---
|
||||
Use ASCII 3 (Ctrl-c) or 4 (ctrl-d) inputs to determine whether to
|
||||
send a SIGKILL event. Other characters may also be selected.
|
||||
|
||||
REVISIT: Traditionally Ctrl-C would generate SIGINT. Ctrl-D is the
|
||||
End-of-File character that should close the stream.
|
||||
|
||||
menuconfig 16550_UART
|
||||
bool "16550 UART Chip support"
|
||||
default n
|
||||
@@ -151,6 +131,28 @@ config SERIAL_TERMIOS
|
||||
If this is not defined, then the terminal settings (baud, parity, etc).
|
||||
are not configurable at runtime; serial streams cannot be flushed, etc..
|
||||
|
||||
config TTY_SIGKILL
|
||||
bool "Support SIGKILL"
|
||||
default n
|
||||
select SIG_DEFAULT
|
||||
depends on !DISABLE_SIGNALS && 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 in the Termios
|
||||
c_lflag.
|
||||
|
||||
config TTY_SIGKILL_CHAR
|
||||
int "Serial parse SIGKILL characters"
|
||||
default 3 if SERIAL_CONSOLE
|
||||
default 4 if !SERIAL_CONSOLE
|
||||
depends on TTY_SIGKILL
|
||||
---help---
|
||||
Use ASCII 3 (Ctrl-c) or 4 (ctrl-d) inputs to determine whether to
|
||||
send a SIGKILL event. Other characters may also be selected.
|
||||
|
||||
REVISIT: Traditionally Ctrl-C would generate SIGINT. Ctrl-D is the
|
||||
End-of-File character that should close the stream.
|
||||
|
||||
#
|
||||
# Serial console selection
|
||||
#
|
||||
|
||||
+26
-8
@@ -1372,22 +1372,22 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TTY_SIGKILL_CHAR
|
||||
#ifdef CONFIG_TTY_SIGKILL
|
||||
/* Make the given terminal the controlling terminal of the calling process */
|
||||
|
||||
case TIOCSCTTY:
|
||||
{
|
||||
/* REVISIT: This only applies to console devices (TTYs). In
|
||||
* reality, this feature should be controlled by TERMIOS ISIG
|
||||
* c_lflag setting.
|
||||
/* Check if the ISIG flag is set in the termios c_lflag to enable
|
||||
* this feature. This flag is set automatically for a serial console
|
||||
* device.
|
||||
*/
|
||||
|
||||
if (dev->isconsole)
|
||||
if ((dev->tc_lflag & ISIG) != 0)
|
||||
{
|
||||
/* Save the PID of the recipient of the SIGKILL signal. */
|
||||
|
||||
dev->pid = (pid_t)arg;
|
||||
DEBUGASSERT((unsigned long)dev->pid = arg);
|
||||
DEBUGASSERT((unsigned long)(dev->pid) == arg);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1435,6 +1435,17 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
dev->tc_iflag = termiosp->c_iflag;
|
||||
dev->tc_oflag = termiosp->c_oflag;
|
||||
dev->tc_lflag = termiosp->c_lflag;
|
||||
|
||||
#ifdef CONFIG_TTY_SIGKILL
|
||||
/* If the ISIG flag has been cleared in c_lflag, then un-
|
||||
* register the controlling terminal.
|
||||
*/
|
||||
|
||||
if ((dev->tc_lflag & ISIG) == 0)
|
||||
{
|
||||
dev->pid = (pid_t)-1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1600,10 +1611,17 @@ errout:
|
||||
|
||||
int uart_register(FAR const char *path, FAR uart_dev_t *dev)
|
||||
{
|
||||
#ifdef CONFIG_TTY_SIGKILL_CHAR
|
||||
#ifdef CONFIG_TTY_SIGKILL
|
||||
/* Initialize of the task that will receive SIGKILL signals. */
|
||||
|
||||
dev->pid = -1;
|
||||
dev->pid = (pid_t)-1;
|
||||
|
||||
/* If this UART is a serial console, then enable signals by default */
|
||||
|
||||
if (dev->isconsole)
|
||||
{
|
||||
dev->tc_lflag |= ISIG;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize semaphores */
|
||||
|
||||
@@ -206,8 +206,8 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
||||
|
||||
if (dev->pid >= 0 && ch == CONFIG_TTY_SIGKILL_CHAR)
|
||||
{
|
||||
/* Yes.. not the the kill is needed and do not put the character into
|
||||
* the Rx buffer. It should not be read as normal data.
|
||||
/* Yes.. note that the kill is needed and do not put the character
|
||||
* into the Rx buffer. It should not be read as normal data.
|
||||
*/
|
||||
|
||||
needkill = true;
|
||||
|
||||
@@ -286,10 +286,9 @@ struct uart_dev_s
|
||||
tcflag_t tc_iflag; /* Input modes */
|
||||
tcflag_t tc_oflag; /* Output modes */
|
||||
tcflag_t tc_lflag; /* Local modes */
|
||||
#ifdef CONFIG_TTY_SIGKILL
|
||||
pid_t pid; /* Thread PID to receive SIGKILL signals (-1 if none) */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SERIAL_SIGKILL_CHAR
|
||||
pid_t pid; /* Thread PID to receive SIGKILL signals (-1 if none) */
|
||||
#endif
|
||||
|
||||
/* Semaphores */
|
||||
|
||||
Reference in New Issue
Block a user