git: 66483838039b - main - systat: Handle SIGWINCH to properly window resizing and adjust -swap disk stat based on new size.
Michael Reifenberger
mr at FreeBSD.org
Wed Apr 21 18:34:43 UTC 2021
The branch main has been updated by mr:
URL: https://cgit.FreeBSD.org/src/commit/?id=66483838039b21a20d748448f8916a73ec419691
commit 66483838039b21a20d748448f8916a73ec419691
Author: Michael Reifenberger <mr at FreeBSD.org>
AuthorDate: 2021-04-21 18:31:58 +0000
Commit: Michael Reifenberger <mr at FreeBSD.org>
CommitDate: 2021-04-21 18:31:58 +0000
systat: Handle SIGWINCH to properly window resizing and adjust
-swap disk stat based on new size.
Display corrupts after resizing a window.
Process SIGWINCH to redraw all window.
Submitted by: Yoshihiro Ota ota at j.email.ne.jp
Differential Revision: https://reviews.freebsd.org/D29337
---
usr.bin/systat/devs.c | 8 +-------
usr.bin/systat/devs.h | 4 +++-
usr.bin/systat/main.c | 16 ++++++++++++++++
usr.bin/systat/swap.c | 4 ++--
4 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c
index b293796c2c77..87d04f989ea3 100644
--- a/usr.bin/systat/devs.c
+++ b/usr.bin/systat/devs.c
@@ -426,12 +426,6 @@ dsshow2(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct s
putlongdouble(device_busy, diskrow + 4, lc, 5, 0, 0);
}
-static void
-dsshow3(int diskcol, int diskrow, int dn, int lc, struct statinfo *now, struct statinfo *then)
-{
- dsshow2(diskcol, diskrow, dn, lc, now, then);
-}
-
void
dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct statinfo *then)
{
@@ -439,5 +433,5 @@ dsshow(int maxdrives, int diskcol, int diskrow, struct statinfo *now, struct sta
for (i = 0, lc = 0; i < num_devices && lc < maxdrives; i++)
if (dev_select[i].selected)
- dsshow3(diskcol, diskrow, i, ++lc, now, then);
+ dsshow2(diskcol, diskrow, i, ++lc, now, then);
}
diff --git a/usr.bin/systat/devs.h b/usr.bin/systat/devs.h
index cbedd844290e..79a44a6c3f5e 100644
--- a/usr.bin/systat/devs.h
+++ b/usr.bin/systat/devs.h
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 1998 David E. O'Brien
- * 2015 Yoshihiro Ota
+ * 2015, 2021 Yoshihiro Ota
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,8 @@
#include <devstat.h>
+#define DISKHIGHT 5
+
int dsinit(int);
void dsgetinfo(struct statinfo *);
int dscmd(const char *, const char *, int, struct statinfo *);
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index b5a19d381ada..b84351379f41 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -135,6 +135,21 @@ parse_cmd_args (int argc, char **argv)
}
+static void
+resize(int signo __unused)
+{
+
+ endwin();
+ refresh();
+ clear();
+
+ CMDLINE = LINES - 1;
+ labels();
+ display();
+ status();
+}
+
+
int
main(int argc, char **argv)
{
@@ -191,6 +206,7 @@ main(int argc, char **argv)
signal(SIGINT, die);
signal(SIGQUIT, die);
signal(SIGTERM, die);
+ signal(SIGWINCH, resize);
/*
* Initialize display. Load average appears in a one line
diff --git a/usr.bin/systat/swap.c b/usr.bin/systat/swap.c
index 29b04df0157f..6052ca0d877b 100644
--- a/usr.bin/systat/swap.c
+++ b/usr.bin/systat/swap.c
@@ -136,7 +136,7 @@ labelswap(void)
werase(wnd);
- dslabel(12, 0, 18);
+ dslabel(12, 0, LINES - DISKHIGHT - 1);
if (kvnsw <= 0) {
mvwprintw(wnd, 0, 0, "(swap not configured)");
@@ -162,7 +162,7 @@ showswap(void)
if (kvnsw != okvnsw)
labelswap();
- dsshow(12, 0, 18, &cur_dev, &last_dev);
+ dsshow(12, 0, LINES - DISKHIGHT - 1, &cur_dev, &last_dev);
if (kvnsw <= 0)
return;
More information about the dev-commits-src-main
mailing list