lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <gho6oczk2f.fsf@gouders.net>
Date: Fri, 05 Dec 2025 22:37:44 +0100
From: Dirk Gouders <dirk@...ders.net>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby
 <jslaby@...e.com>, Al Viro <viro@...iv.linux.org.uk>
Cc: linux-kernel@...r.kernel.org, linux-newbie@...r.kernel.org
Subject: pty: childs don't always react on close(2)

Hi,

chances are high, that I am doing a stupid mistake, because experienced
programmers already would have noticed problems with ptys.
But if you have the time, perhaps you could help me undestand the
following problem:

I am working on a program (a terminal pager [1]) that works with
ptys to allow users to have several manual pages open and reload them
when terminals are resized.

I now noticed, that a close on a pty file descriptor doesn't cause the
child process to exit and a waitpid(2) hangs forever or gets interrupted
(when used without WNOHANG) -- it seems the child doesn't get noticed
about the close(2) on the other end.

Curious is that I notice this only if more than one ptys are in use --
with a single one everything is OK (see attached sample program and test
it with only one pty).


I would be very glad if you could tell me if I am correct to expect that
if I close(2) a pty file descriptor the other end should notice that and
I could assume a waitpid(2) to succeed.
And perhaps, you could tell me which mistake I am doing.

I prepared a small test-case that reproduces the problem, at least here.
If that program is modified to work with just one child, everything
works as expected, when the second child is used, the waitpid() hangs...

Apologies, if this is not the right place and if I should have asked
somewhere else.

Regards,

Dirk

[1] https://github.com/dgouders/lsp


View attachment "test-close-pty.c" of type "text/plain" (2031 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ