bug-ncurses
[Top][All Lists]
Advanced

[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: Thu, 5 Oct 2023 09:35:04 +0200

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

 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

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]