Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org
Cc: dwagner@suse.de, hare@suse.com, kbusch@kernel.org, hch@lst.de,
	gjoyce@linux.ibm.com, wenxiong@linux.ibm.com
Subject: [PATCH 5/7] nvme: add sigaction for SIGWINCH
Date: Thu, 30 Apr 2026 16:22:26 +0530	[thread overview]
Message-ID: <20260430105234.1172446-6-nilay@linux.ibm.com> (raw)
In-Reply-To: <20260430105234.1172446-1-nilay@linux.ibm.com>

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@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



  parent reply	other threads:[~2026-04-30 10:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-30 10:52 [PATCH 0/7] nvme-cli: add nvme top command for real-time monitoring Nilay Shroff
2026-04-30 10:52 ` [PATCH 1/7] nvme: add support for unsigned and long types in table_get_value_width() Nilay Shroff
2026-04-30 10:52 ` [PATCH 2/7] nvme: use table_get_value_width() in table_print_centered() Nilay Shroff
2026-04-30 10:52 ` [PATCH 3/7] nvme: add support for float and double types in table_print_XXX() Nilay Shroff
2026-04-30 10:52 ` [PATCH 4/7] nvme: allow table output to be directed to a FILE stream Nilay Shroff
2026-04-30 10:52 ` Nilay Shroff [this message]
2026-04-30 10:52 ` [PATCH 6/7] nvme: add generic top-like dashboard framework Nilay Shroff
2026-04-30 10:52 ` [PATCH 7/7] nvme: add nvme top command Nilay Shroff
2026-05-03 17:40 ` [PATCH 0/7] nvme-cli: add nvme top command for real-time monitoring Daniel Wagner
2026-05-07 16:28 ` Daniel Wagner
2026-05-11  5:46   ` Nilay Shroff
2026-05-10 22:34 ` Sagi Grimberg
2026-05-11 11:59   ` Nilay Shroff
2026-05-11 12:54     ` Sagi Grimberg
2026-05-11 14:04       ` Nilay Shroff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260430105234.1172446-6-nilay@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=dwagner@suse.de \
    --cc=gjoyce@linux.ibm.com \
    --cc=hare@suse.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=wenxiong@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox