On Sat, Jan 21, 2023 at 08:55:26AM +0100, Sven Joachim wrote: > It does not happen very often that somebody replies to an over 20 years > old bug, and this seems to have escaped both my and upstream's > attention. Thomas, could you please have a look?
I've started looking. Given the size of the patch, it's going to take some time to investigate. - Most of the items in question date back to the mid-1990s. - There's also the consideration of compatbility with other systems. fwiw, here's a slice from tset.c in ncurses 4.2: 0.1 (tom 17-Sep-95): /* 0.1 (tom 17-Sep-95): * Reset the terminal mode bits to a sensible state. Very useful after 0.1 (tom 17-Sep-95): * a child program dies in raw mode. 0.1 (tom 17-Sep-95): */ 0.1 (tom 17-Sep-95): static void 0.1 (tom 17-Sep-95): reset_mode(void) 0.1 (tom 17-Sep-95): { 0.5 (tom 30-Nov-95): #ifdef TERMIOS 0.1 (tom 17-Sep-95): tcgetattr(STDERR_FILENO, &mode); 0.5 (tom 30-Nov-95): #else 0.15 (tom 20-Aug-96): stty(STDERR_FILENO,&mode); 0.5 (tom 30-Nov-95): #endif 0.1 (tom 17-Sep-95): 0.5 (tom 30-Nov-95): #ifdef TERMIOS 0.1 (tom 17-Sep-95): #if defined(VDISCARD) && defined(CDISCARD) 0.1 (tom 17-Sep-95): mode.c_cc[VDISCARD] = CHK(mode.c_cc[VDISCARD], CDISCARD); 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): mode.c_cc[VEOF] = CHK(mode.c_cc[VEOF], CEOF); 0.1 (tom 17-Sep-95): mode.c_cc[VERASE] = CHK(mode.c_cc[VERASE], CERASE); 0.1 (tom 17-Sep-95): #if defined(VFLUSH) && defined(CFLUSH) 0.1 (tom 17-Sep-95): mode.c_cc[VFLUSH] = CHK(mode.c_cc[VFLUSH], CFLUSH); 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): mode.c_cc[VINTR] = CHK(mode.c_cc[VINTR], CINTR); 0.1 (tom 17-Sep-95): mode.c_cc[VKILL] = CHK(mode.c_cc[VKILL], CKILL); 0.1 (tom 17-Sep-95): #if defined(VLNEXT) && defined(CLNEXT) 0.1 (tom 17-Sep-95): mode.c_cc[VLNEXT] = CHK(mode.c_cc[VLNEXT], CLNEXT); 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): mode.c_cc[VQUIT] = CHK(mode.c_cc[VQUIT], CQUIT); 0.1 (tom 17-Sep-95): #if defined(VREPRINT) && defined(CRPRNT) 0.1 (tom 17-Sep-95): mode.c_cc[VREPRINT] = CHK(mode.c_cc[VREPRINT], CRPRNT); 0.1 (tom 17-Sep-95): #endif 0.13 (tom 25-May-96): #if defined(VSTART) && defined(CSTART) 0.1 (tom 17-Sep-95): mode.c_cc[VSTART] = CHK(mode.c_cc[VSTART], CSTART); 0.13 (tom 25-May-96): #endif 0.13 (tom 25-May-96): #if defined(VSTOP) && defined(CSTOP) 0.1 (tom 17-Sep-95): mode.c_cc[VSTOP] = CHK(mode.c_cc[VSTOP], CSTOP); 0.13 (tom 25-May-96): #endif 0.13 (tom 25-May-96): #if defined(VSUSP) && defined(CSUSP) 0.1 (tom 17-Sep-95): mode.c_cc[VSUSP] = CHK(mode.c_cc[VSUSP], CSUSP); 0.13 (tom 25-May-96): #endif 0.1 (tom 17-Sep-95): #if defined(VWERASE) && defined(CWERASE) 0.1 (tom 17-Sep-95): mode.c_cc[VWERASE] = CHK(mode.c_cc[VWERASE], CWERASE); 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): 0.1 (tom 17-Sep-95): mode.c_iflag &= ~(IGNBRK | PARMRK | INPCK | ISTRIP | INLCR | IGNCR 0.1 (tom 17-Sep-95): #ifdef IUCLC 0.1 (tom 17-Sep-95): | IUCLC 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef IXANY 0.1 (tom 17-Sep-95): | IXANY 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): | IXOFF); 0.1 (tom 17-Sep-95): 0.1 (tom 17-Sep-95): mode.c_iflag |= (BRKINT | IGNPAR | ICRNL | IXON 0.1 (tom 17-Sep-95): #ifdef IMAXBEL 0.1 (tom 17-Sep-95): | IMAXBEL 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): ); 0.1 (tom 17-Sep-95): 0.1 (tom 17-Sep-95): mode.c_oflag &= ~(0 0.1 (tom 17-Sep-95): #ifdef OLCUC 0.1 (tom 17-Sep-95): | OLCUC 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef OCRNL 0.1 (tom 17-Sep-95): | OCRNL 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef ONOCR 0.1 (tom 17-Sep-95): | ONOCR 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef ONLRET 0.1 (tom 17-Sep-95): | ONLRET 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef OFILL 0.1 (tom 17-Sep-95): | OFILL 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef OFDEL 0.1 (tom 17-Sep-95): | OFDEL 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef NLDLY 0.1 (tom 17-Sep-95): | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): ); 0.1 (tom 17-Sep-95): 0.1 (tom 17-Sep-95): mode.c_oflag |= (OPOST 0.1 (tom 17-Sep-95): #ifdef ONLCR 0.1 (tom 17-Sep-95): | ONLCR 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): ); 0.1 (tom 17-Sep-95): 0.1 (tom 17-Sep-95): mode.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | CLOCAL); 0.1 (tom 17-Sep-95): mode.c_cflag |= (CS8 | CREAD); 0.13 (tom 25-May-96): mode.c_lflag &= ~(ECHONL | NOFLSH 0.13 (tom 25-May-96): #ifdef TOSTOP 0.13 (tom 25-May-96): | TOSTOP 0.13 (tom 25-May-96): #endif 0.1 (tom 17-Sep-95): #ifdef ECHOPTR 0.1 (tom 17-Sep-95): | ECHOPRT 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef XCASE 0.1 (tom 17-Sep-95): | XCASE 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): ); 0.1 (tom 17-Sep-95): 0.1 (tom 17-Sep-95): mode.c_lflag |= (ISIG | ICANON | ECHO | ECHOE | ECHOK 0.1 (tom 17-Sep-95): #ifdef ECHOCTL 0.1 (tom 17-Sep-95): | ECHOCTL 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): #ifdef ECHOKE 0.1 (tom 17-Sep-95): | ECHOKE 0.1 (tom 17-Sep-95): #endif 0.1 (tom 17-Sep-95): ); 0.5 (tom 30-Nov-95): #endif 0.1 (tom 17-Sep-95): 0.5 (tom 30-Nov-95): #ifdef TERMIOS 0.1 (tom 17-Sep-95): tcsetattr(STDERR_FILENO, TCSADRAIN, &mode); 0.5 (tom 30-Nov-95): #else 0.5 (tom 30-Nov-95): stty(STDERR_FILENO, &mode); 0.15 (tom 20-Aug-96): #endif 0.1 (tom 17-Sep-95): } > Cheers, > Sven > > On 2022-12-06 15:44 -0800, Ben Wong wrote: > > > Package: ncurses-bin > > Version: 6.3+20220423-2 > > Followup-For: Bug #60377 > > Control: tags -1 patch > > Control: tags -1 patch > > > > Dear Maintainer, > > > > This is still a problem. It causes my VT340 serial terminal to hang, > > but not immediately. It happens the next time a program tries to open > > /dev/ttyUSB0, for example, getty after logging out. I presume this > > hasn't been fixed because the bug only affects hardware terminals that > > lack a carrier detect line (such as any DEC terminal connected via > > DEC423 MMJ). > > > > If anything, clocal ought to be asserted by default, not disabled. > > However, I suggest that `reset` should do neither. The man page for > > reset is clear on what it does and it does not mention clocal. I have > > attached a patch which brings the program back into line with its > > documentation. > > > > Thank you, > > > > --Ben > > > > > > > > -- System Information: > > Debian Release: bookworm/sid > > APT prefers testing > > APT policy: (500, 'testing') > > Architecture: amd64 (x86_64) > > > > Kernel: Linux 6.0.0-4-amd64 (SMP w/8 CPU threads; PREEMPT) > > Kernel taint flags: TAINT_SOFTLOCKUP > > Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE > > not set > > Shell: /bin/sh linked to /usr/bin/dash > > Init: systemd (via /run/systemd/system) > > LSM: AppArmor: enabled > > > > Versions of packages ncurses-bin depends on: > > ii libc6 2.36-6 > > ii libtinfo6 6.3+20220423-2 > > > > ncurses-bin recommends no packages. > > > > ncurses-bin suggests no packages. > > > > -- no debconf information > > > > --- reset_cmd.c.orig 2021-10-02 11:08:44.000000000 -0700 > > +++ reset_cmd.c 2022-11-22 16:00:29.005361817 -0800 > > @@ -190,13 +190,14 @@ > > > > /* > > * Reset the terminal mode bits to a sensible state. Very useful after > > - * a child program dies in raw mode. > > + * a child program dies in raw mode. Requires termios(3) to work. > > */ > > void > > reset_tty_settings(int fd, TTY * tty_settings, int noset) > > { > > GET_TTY(fd, tty_settings); > > > > + /* First reset any special characters to their default values */ > > #ifdef TERMIOS > > #if defined(VDISCARD) && defined(CDISCARD) > > reset_char(VDISCARD, CDISCARD); > > @@ -228,94 +229,38 @@ > > reset_char(VWERASE, CWERASE); > > #endif > > > > - tty_settings->c_iflag &= ~((unsigned) (IGNBRK > > - | PARMRK > > - | INPCK > > - | ISTRIP > > - | INLCR > > - | IGNCR > > -#ifdef IUCLC > > - | IUCLC > > -#endif > > -#ifdef IXANY > > - | IXANY > > -#endif > > - | IXOFF)); > > > > + /* Next, the reset command does the following > > + * > > + * sets cooked and echo modes, > > + * turns off cbreak and raw modes and > > + * turns on newline translation on output. > > + * > > + * It does not mess with other settings, such as IXOFF and CLOCAL, > > + * as the correct values depend upon what type of terminal (and > > + * even what type of serial cable) is being used. > > + * > > + * Users who need a blunter instrument can try `stty sane` which > > + * makes presumptions about a "typical" setup. > > + */ > > + > > + /* "Cooked" means: brkint ignpar istrip icrnl ixon opost isig icanon */ > > + /* Setting cooked automatically turns off "raw" and "cbreak" */ > > tty_settings->c_iflag |= (BRKINT > > - | IGNPAR > > - | ICRNL > > - | IXON > > -#ifdef IMAXBEL > > - | IMAXBEL > > -#endif > > - ); > > + | IGNPAR > > + | ISTRIP > > + | ICRNL /* Input maps CR to NL */ > > + | IXON); > > > > - tty_settings->c_oflag &= ~((unsigned) (0 > > -#ifdef OLCUC > > - | OLCUC > > -#endif > > -#ifdef OCRNL > > - | OCRNL > > -#endif > > -#ifdef ONOCR > > - | ONOCR > > -#endif > > -#ifdef ONLRET > > - | ONLRET > > -#endif > > -#ifdef OFILL > > - | OFILL > > -#endif > > -#ifdef OFDEL > > - | OFDEL > > -#endif > > -#ifdef NLDLY > > - | NLDLY > > -#endif > > -#ifdef CRDLY > > - | CRDLY > > -#endif > > -#ifdef TABDLY > > - | TABDLY > > -#endif > > -#ifdef BSDLY > > - | BSDLY > > -#endif > > -#ifdef VTDLY > > - | VTDLY > > -#endif > > -#ifdef FFDLY > > - | FFDLY > > -#endif > > - )); > > + tty_settings->c_iflag &= ~(INLCR); /* Input does not map NL to CR */ > > > > tty_settings->c_oflag |= (OPOST > > #ifdef ONLCR > > - | ONLCR > > + | ONLCR /* Output maps NL to CR-NL */ > > #endif > > - ); > > + ); > > > > - tty_settings->c_cflag &= ~((unsigned) (CSIZE > > - | CSTOPB > > - | PARENB > > - | PARODD > > - | CLOCAL)); > > - tty_settings->c_cflag |= (CS8 | CREAD); > > - tty_settings->c_lflag &= ~((unsigned) (ECHONL > > - | NOFLSH > > -#ifdef TOSTOP > > - | TOSTOP > > -#endif > > -#ifdef ECHOPTR > > - | ECHOPRT > > -#endif > > -#ifdef XCASE > > - | XCASE > > -#endif > > - )); > > - > > - tty_settings->c_lflag |= (ISIG > > + tty_settings->c_lflag |= (ISIG /* Generate signal on ^C, > > ^Z, etc */ > > | ICANON > > | ECHO > > | ECHOE > > @@ -327,7 +272,7 @@ > > | ECHOKE > > #endif > > ); > > -#endif > > +#endif /* Matches #ifdef TERMIOS */ > > > > if (!noset) { > > SET_TTY(fd, tty_settings); > -- Thomas E. Dickey <dic...@invisible-island.net> https://invisible-island.net
signature.asc
Description: PGP signature