Re: pty: childs don't always react on close(2)

From: Al Viro

Date: Fri Dec 05 2025 - 16:48:34 EST


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.