[PATCH 5/7] nvme: add sigaction for SIGWINCH

Nilay Shroff nilay at linux.ibm.com
Thu Apr 30 03:52:26 PDT 2026


Add a sigaction handler for SIGWINCH so that nvme-top can
detect terminal window size changes.

This allows the dashboard layout to be adjusted and redrawn
when the terminal is resized.

Signed-off-by: Nilay Shroff <nilay at linux.ibm.com>
---
 util/sighdl.c | 14 +++++++++++---
 util/sighdl.h |  1 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/util/sighdl.c b/util/sighdl.c
index 146591e5d..f6b3c4a87 100644
--- a/util/sighdl.c
+++ b/util/sighdl.c
@@ -6,10 +6,14 @@
 #include "sighdl.h"
 
 bool nvme_sigint_received;
+bool nvme_sigwinch_received;
 
-static void nvme_sigint_handler(int signum)
+static void nvme_sig_handler(int signum)
 {
-	nvme_sigint_received = true;
+	if (signum == SIGINT)
+		nvme_sigint_received = true;
+	else if (signum == SIGWINCH)
+		nvme_sigwinch_received = true;
 }
 
 int nvme_install_sigint_handler(void)
@@ -17,12 +21,16 @@ int nvme_install_sigint_handler(void)
 	struct sigaction act;
 
 	sigemptyset(&act.sa_mask);
-	act.sa_handler = nvme_sigint_handler;
+	act.sa_handler = nvme_sig_handler;
 	act.sa_flags = 0;
 
 	nvme_sigint_received = false;
 	if (sigaction(SIGINT, &act, NULL) == -1)
 		return -errno;
 
+	nvme_sigwinch_received = false;
+	if (sigaction(SIGWINCH, &act, NULL) == -1)
+		return -errno;
+
 	return 0;
 }
diff --git a/util/sighdl.h b/util/sighdl.h
index 8d5d1c126..48afd8b20 100644
--- a/util/sighdl.h
+++ b/util/sighdl.h
@@ -5,6 +5,7 @@
 #include <stdbool.h>
 
 extern bool nvme_sigint_received;
+extern bool nvme_sigwinch_received;
 
 int nvme_install_sigint_handler(void);
 
-- 
2.53.0




More information about the Linux-nvme mailing list