serial: Shouldn't mangle pid when ISIG is changed
Let's check ISIG flag directly instead Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I060f70eefc79b1c34aa11ed4071179d2ae5fa5ca
This commit is contained in:
parent
c6b51771f0
commit
650e18baa1
@ -1362,20 +1362,12 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
/* Make the controlling terminal of the calling process */
|
/* Make the controlling terminal of the calling process */
|
||||||
|
|
||||||
case TIOCSCTTY:
|
case TIOCSCTTY:
|
||||||
{
|
|
||||||
/* 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->tc_lflag & ISIG) != 0)
|
|
||||||
{
|
{
|
||||||
/* Save the PID of the recipient of the SIGINT signal. */
|
/* Save the PID of the recipient of the SIGINT signal. */
|
||||||
|
|
||||||
dev->pid = (pid_t)arg;
|
dev->pid = (pid_t)arg;
|
||||||
DEBUGASSERT((unsigned long)(dev->pid) == arg);
|
DEBUGASSERT((unsigned long)(dev->pid) == arg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1421,17 +1413,6 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
dev->tc_iflag = termiosp->c_iflag;
|
dev->tc_iflag = termiosp->c_iflag;
|
||||||
dev->tc_oflag = termiosp->c_oflag;
|
dev->tc_oflag = termiosp->c_oflag;
|
||||||
dev->tc_lflag = termiosp->c_lflag;
|
dev->tc_lflag = termiosp->c_lflag;
|
||||||
|
|
||||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
|
||||||
/* 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;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -373,9 +373,11 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
|
|||||||
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
#if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
|
||||||
int signo = 0;
|
int signo = 0;
|
||||||
|
|
||||||
/* Check if the SIGINT character is anywhere in the newly received DMA buffer. */
|
/* Check if the SIGINT character is anywhere in the newly received DMA
|
||||||
|
* buffer.
|
||||||
|
*/
|
||||||
|
|
||||||
if (dev->pid >= 0)
|
if (dev->pid >= 0 && (dev->tc_lflag & ISIG))
|
||||||
{
|
{
|
||||||
signo = uart_recvchars_signo(dev);
|
signo = uart_recvchars_signo(dev);
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,8 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
|||||||
|
|
||||||
if (nbuffered >= watermark)
|
if (nbuffered >= watermark)
|
||||||
{
|
{
|
||||||
/* Let the lower level driver know that the watermark level has been
|
/* Let the lower level driver know that the watermark level has
|
||||||
* crossed. It will probably activate RX flow control.
|
* been crossed. It will probably activate RX flow control.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (uart_rxflowcontrol(dev, nbuffered, true))
|
if (uart_rxflowcontrol(dev, nbuffered, true))
|
||||||
@ -196,8 +196,9 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Check if RX buffer is full and allow serial low-level driver to pause
|
/* Check if RX buffer is full and allow serial low-level driver to
|
||||||
* processing. This allows proper utilization of hardware flow control.
|
* pause processing. This allows proper utilization of hardware flow
|
||||||
|
* control.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (is_full)
|
if (is_full)
|
||||||
@ -217,9 +218,12 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
|||||||
ch = uart_receive(dev, &status);
|
ch = uart_receive(dev, &status);
|
||||||
|
|
||||||
#ifdef CONFIG_TTY_SIGINT
|
#ifdef CONFIG_TTY_SIGINT
|
||||||
/* Is this the special character that will generate the SIGINT signal? */
|
/* Is this the special character that will generate the SIGINT
|
||||||
|
* signal?
|
||||||
|
*/
|
||||||
|
|
||||||
if (dev->pid >= 0 && ch == CONFIG_TTY_SIGINT_CHAR)
|
if (dev->pid >= 0 && (dev->tc_lflag & ISIG) &&
|
||||||
|
ch == CONFIG_TTY_SIGINT_CHAR)
|
||||||
{
|
{
|
||||||
/* Yes.. note that the kill is needed and do not put the character
|
/* 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.
|
* into the Rx buffer. It should not be read as normal data.
|
||||||
@ -230,9 +234,12 @@ void uart_recvchars(FAR uart_dev_t *dev)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_TTY_SIGSTP
|
#ifdef CONFIG_TTY_SIGSTP
|
||||||
/* Is this the special character that will generate the SIGSTP signal? */
|
/* Is this the special character that will generate the SIGSTP
|
||||||
|
* signal?
|
||||||
|
*/
|
||||||
|
|
||||||
if (dev->pid >= 0 && ch == CONFIG_TTY_SIGSTP_CHAR)
|
if (dev->pid >= 0 && (dev->tc_lflag & ISIG) &&
|
||||||
|
ch == CONFIG_TTY_SIGSTP_CHAR)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_TTY_SIGINT
|
#ifdef CONFIG_TTY_SIGINT
|
||||||
/* Give precedence to SIGINT */
|
/* Give precedence to SIGINT */
|
||||||
|
Loading…
Reference in New Issue
Block a user