From a69a46eafd5f250f622c0a8812ad2380ef542bda Mon Sep 17 00:00:00 2001 From: Hendrik Brueckner Date: Mon, 6 Jul 2026 11:39:52 +0200 Subject: [PATCH] iucvterm/iucvtty: Close PTY slave fd after fork MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PTY slave file descriptor is the controlling terminal allocated for the child process. When all file descriptors are being closed, a SIGHUP is triggered for the child process. Keeping the file descriptor in the parent open would prevent the SIGHUP to be delivered to the child process. For proper SIGHUP processing, close the file descriptor in the parent process. Acked-by: Steffen Eiden Signed-off-by: Hendrik Brueckner Signed-off-by: Jan Höppner --- iucvterm/src/iucvtty.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/iucvterm/src/iucvtty.c b/iucvterm/src/iucvtty.c index f1dbaa8d..5296132e 100644 --- a/iucvterm/src/iucvtty.c +++ b/iucvterm/src/iucvtty.c @@ -123,6 +123,9 @@ static int iucvtty_worker(int client, int master, int slave, exit(3); /* we only reach here if exec has failed */ } + /* Close slave fd to properly handle SIGHUP for the child process */ + close(slave); + /* setup buffers */ msg = malloc(MSG_BUFFER_SIZE); if (msg == NULL) {