In article <yddddkjc+xxgw...@pony.stderr.spb.ru>, Valery Ushakov <u...@stderr.spb.ru> wrote: >On Sat, Jan 01, 2022 at 21:49:00 +0000, RVP wrote: > >> OK, but, I think we can do better than rudely sending processes a SIGHUP. >> Using the BSD-native /dev/ptm device (via openpty(3) & friends) instead of >> /dev/ptmx seems to do the right thing: EOF when the PTY master is closed. >> >> File a PR (Category: pkg) > >Why pkg? This is a kernel bug. POSIX doesn't seem to say anything >about this, but Christos pointed out e.g. > > https://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/pty.7.html > >that says > > A read() request made on the slave side of a pty after the master > side is closed returns 0 bytes. Closing the master side of a pty > sends a SIGHUP hangup signal to the tty process group number of the > corresponding slave side and flushes pending input and output. > >Solaris docs for (STREAMS-based) ptys say: > > When the master device is closed, an M_HANGUP message is sent to the > slave device to render the device unusable. The process on the slave > side gets the errno ENXIO when attempting to write on that stream, > but it will be able to read any data remaining on the stream head > read queue. When all the data has been read, read(2) returns 0, > indicating that the stream can no longer be used.
Yes, in the end screen was at fault for setting CLOCAL in the pty which prevented from SIGHUP from being sent. I fixed it. christos