One of the conditions checked by ptcpoll() in order to determine if
writing is possible is missing from the equivalent kqueue filter.
Diff below fixes that, ok?
Index: kern/tty_pty.c
===================================================================
RCS file: /cvs/src/sys/kern/tty_pty.c,v
retrieving revision 1.98
diff -u -p -r1.98 tty_pty.c
--- kern/tty_pty.c 7 Apr 2020 13:27:51 -0000 1.98
+++ kern/tty_pty.c 20 May 2020 09:48:04 -0000
@@ -708,7 +708,8 @@ filt_ptcwrite(struct knote *kn, long hin
if (ISSET(pti->pt_flags, PF_REMOTE)) {
if (tp->t_canq.c_cc == 0)
kn->kn_data = tp->t_canq.c_cn;
- } else if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG(tp)-2)
+ } else if ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG(tp)-2) ||
+ (tp->t_canq.c_cc == 0 && ISSET(tp->t_lflag, ICANON)))
kn->kn_data = tp->t_canq.c_cn -
(tp->t_rawq.c_cc + tp->t_canq.c_cc);
}