]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/um/drivers/chan_user.c
Merge branch 'perf-probes-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / arch / um / drivers / chan_user.c
index 8443d372f67c68faac86ec62c1306556a343e921..cfeb3f4a44afc0ef9cb6a5edf5e08d0d81ec32a1 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
  * Licensed under the GPL
  */
@@ -11,6 +11,7 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 #include "chan_user.h"
+#include "kern_constants.h"
 #include "os.h"
 #include "um_malloc.h"
 #include "user.h"
@@ -74,27 +75,40 @@ void generic_free(void *data)
 
 int generic_console_write(int fd, const char *buf, int n)
 {
+       sigset_t old, no_sigio;
        struct termios save, new;
        int err;
 
        if (isatty(fd)) {
+               sigemptyset(&no_sigio);
+               sigaddset(&no_sigio, SIGIO);
+               if (sigprocmask(SIG_BLOCK, &no_sigio, &old))
+                       goto error;
+
                CATCH_EINTR(err = tcgetattr(fd, &save));
                if (err)
                        goto error;
                new = save;
-               /* The terminal becomes a bit less raw, to handle \n also as
+               /*
+                * The terminal becomes a bit less raw, to handle \n also as
                 * "Carriage Return", not only as "New Line". Otherwise, the new
-                * line won't start at the first column.*/
+                * line won't start at the first column.
+                */
                new.c_oflag |= OPOST;
                CATCH_EINTR(err = tcsetattr(fd, TCSAFLUSH, &new));
                if (err)
                        goto error;
        }
        err = generic_write(fd, buf, n, NULL);
-       /* Restore raw mode, in any case; we *must* ignore any error apart
-        * EINTR, except for debug.*/
-       if (isatty(fd))
+       /*
+        * Restore raw mode, in any case; we *must* ignore any error apart
+        * EINTR, except for debug.
+        */
+       if (isatty(fd)) {
                CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save));
+               sigprocmask(SIG_SETMASK, &old, NULL);
+       }
+
        return err;
 error:
        return -errno;
@@ -167,13 +181,13 @@ static int winch_thread(void *arg)
                exit(1);
        }
 
-       if(ioctl(pty_fd, TIOCSCTTY, 0) < 0){
+       if (ioctl(pty_fd, TIOCSCTTY, 0) < 0) {
                printk(UM_KERN_ERR "winch_thread : TIOCSCTTY failed on "
                       "fd %d err = %d\n", pty_fd, errno);
                exit(1);
        }
 
-       if(tcsetpgrp(pty_fd, os_getpid()) < 0){
+       if (tcsetpgrp(pty_fd, os_getpid()) < 0) {
                printk(UM_KERN_ERR "winch_thread : tcsetpgrp failed on "
                       "fd %d err = %d\n", pty_fd, errno);
                exit(1);