Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1318108

Re: stty blocks forever when the line is already opened (and the tx buffer can't be flushed)

From Richard Genoud <richard.genoud@gmail.com>
Newsgroups linux.kernel
Subject Re: stty blocks forever when the line is already opened (and the tx buffer can't be flushed)
Date 2016-01-26 17:20 +0100
Message-ID <qVevx-6B0-37@gated-at.bofh.it> (permalink)
References <qVevx-6B0-39@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[ sorry for the noise, I forgot to Cc the lkml ]

Hi,
I've found a case were calling
stty -F /dev/ttyS1 clocal
blocks forever.
And I don't know if it's a very old bug or if it's meant to be like that.

Here is how to reproduce the lock :
NB: there's NO modem on ttyS1
stty -F /dev/ttyS1 clocal cread crtscts
cat < /dev/ttyS1

#on another terminal :
echo "dummy" > /dev/ttyS1  # This call doesn't block

stty -F /dev/ttyS1 -crtscts # this blocks forever on ioctl(TCSETSW )


looking at tty_port_close_start(), it's pretty clear that nothing is
flushed until the last user, so it explains why the "echo dummy"
returns directly, despite the crtscts flags.
And in tty_mode_ioctl(), there are the lines:
        case TCSETSW:
                return set_termios(real_tty, p, TERMIOS_WAIT | TERMIOS_OLD);
That explain why the stty blocks.

But this behavior seems really strange.
... Or it's meant to be like that ?


Regards,
Richard

NB: This is actually a real life use case with mgetty, a modem losing
its power and another process trying to speak to the modem.

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: stty blocks forever when the line is already opened (and the tx  buffer can't be flushed) Richard Genoud <richard.genoud@gmail.com> - 2016-01-26 17:20 +0100
  Re: stty blocks forever when the line is already opened (and the tx  buffer can't be flushed) Peter Hurley <peter@hurleysoftware.com> - 2016-01-26 18:20 +0100
    Re: stty blocks forever when the line is already opened (and the tx  buffer can't be flushed) Richard Genoud <richard.genoud@gmail.com> - 2016-01-27 10:20 +0100
      Re: stty blocks forever when the line is already opened (and the tx  buffer can't be flushed) Richard Genoud <richard.genoud@gmail.com> - 2016-01-27 11:30 +0100

csiph-web