Merge branches 'release' and 'stats' into release
[sfrench/cifs-2.6.git] / drivers / char / n_tty.c
index 038056911934c3b60a10a70553702ff33cb070b6..90c3969012a3ce5f5ddb941561a813c6a9a3349b 100644 (file)
@@ -437,7 +437,7 @@ static inline void finish_erasing(struct tty_struct *tty)
  *     @c: character input
  *     @tty: terminal device
  *
- *     Perform erase and neccessary output when an erase character is
+ *     Perform erase and necessary output when an erase character is
  *     present in the stream from the driver layer. Handles the complexities
  *     of UTF-8 multibyte symbols.
  */
@@ -657,7 +657,7 @@ static inline void n_tty_receive_overrun(struct tty_struct *tty)
  *     @c: character
  *
  *     Process a parity error and queue the right data to indicate
- *     the error case if neccessary. Locking as per n_tty_receive_buf.
+ *     the error case if necessary. Locking as per n_tty_receive_buf.
  */
 static inline void n_tty_receive_parity_error(struct tty_struct *tty,
                                              unsigned char c)
@@ -695,17 +695,16 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
                return;
        }
        
-       if (tty->stopped && !tty->flow_stopped &&
-           I_IXON(tty) && I_IXANY(tty)) {
-               start_tty(tty);
-               return;
-       }
-       
        if (I_ISTRIP(tty))
                c &= 0x7f;
        if (I_IUCLC(tty) && L_IEXTEN(tty))
                c=tolower(c);
 
+       if (tty->stopped && !tty->flow_stopped && I_IXON(tty) &&
+           ((I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty)) ||
+            c == INTR_CHAR(tty) || c == QUIT_CHAR(tty)))
+               start_tty(tty);
+
        if (tty->closing) {
                if (I_IXON(tty)) {
                        if (c == START_CHAR(tty))
@@ -769,7 +768,21 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
                signal = SIGTSTP;
                if (c == SUSP_CHAR(tty)) {
 send_signal:
-                       isig(signal, tty, 0);
+                       /*
+                        * Echo character, and then send the signal.
+                        * Note that we do not use isig() here because we want
+                        * the order to be:
+                        * 1) flush, 2) echo, 3) signal
+                        */
+                       if (!L_NOFLSH(tty)) {
+                               n_tty_flush_buffer(tty);
+                               if (tty->driver->flush_buffer)
+                                       tty->driver->flush_buffer(tty);
+                       }
+                       if (L_ECHO(tty))
+                               echo_char(c, tty);
+                       if (tty->pgrp)
+                               kill_pgrp(tty->pgrp, signal, 1);
                        return;
                }
        }