[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-ncurses] Reset clears CLOCAL flag breaking some hardware serial
From: |
Dr. Werner Fink |
Subject: |
Re: [bug-ncurses] Reset clears CLOCAL flag breaking some hardware serial ports |
Date: |
Wed, 18 Oct 2023 10:19:25 +0200 |
On 2023/10/05 03:59:21 -0400, Thomas Dickey wrote:
> On Thu, Oct 05, 2023 at 09:35:04AM +0200, Dr. Werner Fink wrote:
> > On 2023/10/04 10:40:35 +0000, Michal Suchanek wrote:
> > > Hello,
> > >
> > > on some development boards and server BMCs the hardware apparently
> > > lacks the modem control lines.
> > >
> > > The OS correctly sets the CLOCAL flag and the terminal works. However,
> > > when there is a need to reset the terminal after adjusting the TERM
> > > variable the reset tool clears the CLOCAL flag. This is not documented
> > > in the man page nor can I see any reason in the git history why this
> > > functionality was added (in ncurses 4.1 AFAICS).
> >
> > That is back more than 25 years ... ncurses-4.1/progs/tset.c
>
> "more than 25 years" actually goes back to 1995 (28 years), as mentioned here
>
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=60377
>
> call that ncurses 1.9.6:
>
> https://invisible-island.net/ncurses/ncurses-license.html#ncurses_1_9_6
>
> Just changing it may be disruptive, which prompts caution.
>
> In my response on the Debian bug report, I had in mind making a table for
> the manual to explain the change, and perhaps make it an option rather
> than surprise everyone.
>
> > static void
> > reset_mode(void)
> >
> > [...]
> >
> > mode.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | CLOCAL);
> >
> >
> > >
> > > On the affected devices (such as Raspberry Pi) the symptom is that
> > > terminal applications using the alternate screen such as less or vim
> > > keep waiting in the kernel and never start.
> > >
> > > I don't think that the CLOCAL flag is part of what the reset tool
> > > should change much like the terminal baud rate - this is property of
> > > how the terminal is connected, and not the terminal type.
> >
> > I suggest to check if the open file descriptor of the the tty line has
> > set O_NONBLOCK via fcntl/F_GETFL and if so not to clear CLOCAL.
> > Normally opening a a port to a modem blocks until the modem reports
> > carrier detection, therefore O_NONBLOCK is used. Then the first read
> > or write call will wait for carrier to be established.
> >
> > Werner
I can remember an old tool I had written for blogd called isserial.
It simply check if the current input file descriptor has the Modem
Control ioctl TIOCMGET ... means if the ioctl() returns -1 with error
ENOTTY it is a standard terminal line whereas serials lines do not
show an error ENOTTY.
Werner
--
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
signature.asc
Description: PGP signature