From ae557da4df23356ac8e2c6c49bbf2866a7c3dcbd Mon Sep 17 00:00:00 2001
From: Nic Boet <nic@boet.cc>
Date: Thu, 1 Oct 2026 22:39:42 -0500
Subject: [PATCH] Close the tty after reading the window size

resize_screen() opened the controlling tty to query TIOCGWINSZ and never
closed it, leaking one file descriptor per SIGWINCH. Close it right after
the ioctl, on both the success and error paths.
---
 cmatrix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/cmatrix.c b/cmatrix.c
index 7d8ca39..b42e8d2 100644
--- a/cmatrix.c
+++ b/cmatrix.c
@@ -280,6 +280,7 @@ void resize_screen(void) {
         return;
     }
     result = ioctl(fd, TIOCGWINSZ, &win);
+    close(fd);
     if (result == -1) {
         return;
     }
