I'm writing an expect-style program to interact with a command-line application on Linux. Is there any way that my program can know when the application on the other side of the PTY tries to perform a read
over it?
Ideally, this would be possible without knowing what processes are running on the other side of the PTY (or with only knowledge of the process group). Polling the state of the ptmx file descriptor doesn't work, since I'm always able to write to it, even if that write will be buffered internally by the kernel.