Al Viro writes: > On Fri, Dec 05, 2025 at 10:37:44PM +0100, Dirk Gouders wrote: > >> child_pid1 = forkpty(&pty_fd1, NULL, NULL, NULL); > > You do realize that it will inherit all your opened descriptors, > including pty_fd, right? > > ... >> close(pty_fd); > > ... which doesn't do anything to the second child's descriptor > table, including the descriptor that refers to the same opened file. > IOW, the IO channel (== opened file) is very much opened after > that close() - descriptors refering to it still exist. Oh yes, thank you very much! I use FD_CLOEXEC nearly everywhere in the mentioned program but exactly not for the pty file descriptors. Oh well... For completenes, I'll attach the modified test-case. Would be interesting to hear if there are other possible fixes. Thank you very much, again, Dirk