You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2020/09/25 13:48:37 UTC

[incubator-nuttx] branch master updated: serial: Shouldn't mangle pid when ISIG is changed

This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 650e18b  serial: Shouldn't mangle pid when ISIG is changed
650e18b is described below

commit 650e18baa19c1f4ef952f55d1ea8ef4ac260667a
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Sep 24 18:11:44 2020 +0800

    serial: Shouldn't mangle pid when ISIG is changed
    
    Let's check ISIG flag directly instead
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I060f70eefc79b1c34aa11ed4071179d2ae5fa5ca
---
 drivers/serial/serial.c     | 25 +++----------------------
 drivers/serial/serial_dma.c |  6 ++++--
 drivers/serial/serial_io.c  | 23 +++++++++++++++--------
 3 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 892dd3a..a21a77e 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -1363,18 +1363,10 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
           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;
-                  DEBUGASSERT((unsigned long)(dev->pid) == arg);
-               }
+              dev->pid = (pid_t)arg;
+              DEBUGASSERT((unsigned long)(dev->pid) == arg);
             }
             break;
 #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_oflag = termiosp->c_oflag;
               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;
         }
diff --git a/drivers/serial/serial_dma.c b/drivers/serial/serial_dma.c
index c549efc..5d9888e 100644
--- a/drivers/serial/serial_dma.c
+++ b/drivers/serial/serial_dma.c
@@ -373,9 +373,11 @@ void uart_recvchars_done(FAR uart_dev_t *dev)
 #if defined(CONFIG_TTY_SIGINT) || defined(CONFIG_TTY_SIGSTP)
   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);
     }
diff --git a/drivers/serial/serial_io.c b/drivers/serial/serial_io.c
index 575b90d..e162de9 100644
--- a/drivers/serial/serial_io.c
+++ b/drivers/serial/serial_io.c
@@ -184,8 +184,8 @@ void uart_recvchars(FAR uart_dev_t *dev)
 
       if (nbuffered >= watermark)
         {
-          /* Let the lower level driver know that the watermark level has been
-           * crossed.  It will probably activate RX flow control.
+          /* Let the lower level driver know that the watermark level has
+           * been crossed.  It will probably activate RX flow control.
            */
 
           if (uart_rxflowcontrol(dev, nbuffered, true))
@@ -196,8 +196,9 @@ void uart_recvchars(FAR uart_dev_t *dev)
             }
         }
 #else
-      /* Check if RX buffer is full and allow serial low-level driver to pause
-       * processing. This allows proper utilization of hardware flow control.
+      /* Check if RX buffer is full and allow serial low-level driver to
+       * pause processing. This allows proper utilization of hardware flow
+       * control.
        */
 
       if (is_full)
@@ -217,9 +218,12 @@ void uart_recvchars(FAR uart_dev_t *dev)
       ch = uart_receive(dev, &status);
 
 #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
            * 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
 #endif
 #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
           /* Give precedence to SIGINT */