Commit ce3b642d42f36406112ab474c03d81c5941d9398
Committed by
Linus Torvalds
1 parent
0a765329ed
uml: work around host tcsetattr bug
Under the conditions that UML uses it, tcgetattr is guaranteed to return -EINTR when the console is attached to /dev/ptmx, making generic_console_write hang because it loops, calling tcgetattr until it succeeds. This is a host bug - see http://marc.info/?l=linux-kernel&m=119618990807182&w=2 for the details. This patch works around it by blocking SIGIO while the terminal attributes are being fiddled. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 10 additions and 1 deletions Side-by-side Diff
arch/um/drivers/chan_user.c
... | ... | @@ -74,10 +74,16 @@ |
74 | 74 | |
75 | 75 | int generic_console_write(int fd, const char *buf, int n) |
76 | 76 | { |
77 | + sigset_t old, no_sigio; | |
77 | 78 | struct termios save, new; |
78 | 79 | int err; |
79 | 80 | |
80 | 81 | if (isatty(fd)) { |
82 | + sigemptyset(&no_sigio); | |
83 | + sigaddset(&no_sigio, SIGIO); | |
84 | + if (sigprocmask(SIG_BLOCK, &no_sigio, &old)) | |
85 | + goto error; | |
86 | + | |
81 | 87 | CATCH_EINTR(err = tcgetattr(fd, &save)); |
82 | 88 | if (err) |
83 | 89 | goto error; |
84 | 90 | |
... | ... | @@ -97,8 +103,11 @@ |
97 | 103 | * Restore raw mode, in any case; we *must* ignore any error apart |
98 | 104 | * EINTR, except for debug. |
99 | 105 | */ |
100 | - if (isatty(fd)) | |
106 | + if (isatty(fd)) { | |
101 | 107 | CATCH_EINTR(tcsetattr(fd, TCSAFLUSH, &save)); |
108 | + sigprocmask(SIG_SETMASK, &old, NULL); | |
109 | + } | |
110 | + | |
102 | 111 | return err; |
103 | 112 | error: |
104 | 113 | return -errno; |