From: Peter Hurley <peter@hurleysoftware.com>
To: Wang YanQing <udknight@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
jslaby@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH]TTY: Fix tty can't be restarted by TCXONC ioctl request
Date: Wed, 08 May 2013 14:32:23 -0400 [thread overview]
Message-ID: <518A9A37.9000405@hurleysoftware.com> (raw)
In-Reply-To: <20130508171247.GA6925@udknight>
On 05/08/2013 01:12 PM, Wang YanQing wrote:
> On Wed, May 08, 2013 at 11:18:07AM -0400, Peter Hurley wrote:
>> On 05/08/2013 09:16 AM, Wang YanQing wrote:
>>> On Tue, May 07, 2013 at 07:02:00PM -0700, Greg KH wrote:
>>>> What about Peter's comments on this patch?
>>>>
>>> Peter's comments will import policy,
>>>
>>> I means we should let userspace to decide whether
>>> and when to restart tty with the mechanism of TCXONC
>>> instead of restart tty accidental when make n_tty_set_termios
>>> call.
>>
>> There would be no accidental restart. Userspace is specifically
>> disabling user-controlled output flow control by clearing
>> IXON in termios. Userspace is _expecting_ a 'started' tty.
>>
>> If you insist that this must be controllable from userspace,
>> then that is already possible:
>>
>> tcflow(fd, TCOOFF);
>> tcflow(fd, TCOON);
>
> Indeed you can't do what you said with TCOOFF and TCOON
> if you read the codes, that's what this patch fix.
Perhaps you misunderstood. The snippet above does indeed restart
a tty which has been stopped via STOP_CHAR(tty) and the termios
IXON flag cleared.
Below is a testcase which demonstrates the problem and
the userspace workaround from above.
--- >% ---
/**
* tty_unstop.c
*
* Description: testcase for unsticking stopped tty from userspace
*
* To build testcase:
* gcc tty_unstop.c -o tty_unstop
*
* To build exemplar userspace workaround:
* gcc -D FIX_STOPPED_TTY tty_unstop.c -o tty_unstop
*/
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdarg.h>
static void error_exit(char *f, ...)
{
va_list va;
va_start(va, f);
vprintf(f, va);
printf(": %s\n", strerror(errno));
va_end(va);
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
struct termios termios, save;
char buffer[MAX_CANON];
int err;
ssize_t n;
printf("Pause terminal now with Ctrl+S\n");
sleep(5);
err = tcgetattr(STDIN_FILENO, &termios);
if (err < 0)
error_exit("tcgetattr");
save = termios;
termios.c_iflag &= ~IXON;
err = tcsetattr(STDIN_FILENO, TCSANOW, &termios);
if (err < 0)
error_exit("tcsetattr");
#ifdef FIX_STOPPED_TTY
tcflow(STDIN_FILENO, TCOOFF);
tcflow(STDIN_FILENO, TCOON);
#endif
printf("Enter some text: ");
fflush(stdout);
n = read(STDIN_FILENO, buffer, sizeof(buffer));
if (n < 0)
error_exit("read");
printf("%.*s", (int)n, buffer);
err = tcsetattr(STDIN_FILENO, TCSAFLUSH, &save);
if (err < 0)
error_exit("tcsetattr");
return 0;
}
next prev parent reply other threads:[~2013-05-08 18:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-07 18:47 [PATCH]TTY: Fix tty can't be restarted by TCXONC ioctl request Wang YanQing
2013-05-07 18:58 ` Greg KH
2013-05-08 1:55 ` Wang YanQing
2013-05-08 2:02 ` Greg KH
2013-05-08 13:16 ` Wang YanQing
2013-05-08 15:18 ` Peter Hurley
2013-05-08 17:12 ` Wang YanQing
2013-05-08 18:32 ` Peter Hurley [this message]
2013-05-09 0:42 ` Wang YanQing
2013-05-07 20:50 ` Peter Hurley
2013-05-08 2:00 ` Wang YanQing
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=518A9A37.9000405@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=udknight@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.