vt: selection, handle pending signals in paste_selection
[linux-2.6-microblaze.git] / drivers / tty / vt / selection.c
index 78732fe..44d974d 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/console.h>
 #include <linux/tty_flip.h>
 
+#include <linux/sched/signal.h>
+
 /* Don't take this from <ctype.h>: 011-015 on the screen aren't spaces */
 #define isspace(c)     ((c) == ' ')
 
@@ -350,6 +352,7 @@ int paste_selection(struct tty_struct *tty)
        unsigned int count;
        struct  tty_ldisc *ld;
        DECLARE_WAITQUEUE(wait, current);
+       int ret = 0;
 
        console_lock();
        poke_blanked_console();
@@ -363,6 +366,10 @@ int paste_selection(struct tty_struct *tty)
        add_wait_queue(&vc->paste_wait, &wait);
        while (sel_buffer && sel_buffer_lth > pasted) {
                set_current_state(TASK_INTERRUPTIBLE);
+               if (signal_pending(current)) {
+                       ret = -EINTR;
+                       break;
+               }
                if (tty_throttled(tty)) {
                        schedule();
                        continue;
@@ -378,6 +385,6 @@ int paste_selection(struct tty_struct *tty)
 
        tty_buffer_unlock_exclusive(&vc->port);
        tty_ldisc_deref(ld);
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(paste_selection);