[systemd-devel] [PATCH 3/3] journalctl: add SIGWINCH handler in --follow mode

Dave Reisner dreisner at archlinux.org
Mon Sep 17 16:47:32 PDT 2012


Recalculate the terminal size on SIGWINCH to make sure we take in to
the account the new real estate.
---
 src/journal/journalctl.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 8e52dd5..a04bb05 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -29,6 +29,7 @@
 #include <sys/poll.h>
 #include <time.h>
 #include <getopt.h>
+#include <signal.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <linux/fs.h>
@@ -78,6 +79,10 @@ static enum {
         ACTION_DISK_USAGE,
 } arg_action = ACTION_SHOW;
 
+static recalc_columns(int _unused_ signum) {
+        columns_uncached();
+}
+
 static int help(void) {
 
         printf("%s [OPTIONS...] [MATCH]\n\n"
@@ -175,6 +180,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'f':
                         arg_follow = true;
+                        signal(SIGWINCH, recalc_columns);
                         break;
 
                 case 'o':
-- 
1.7.12



More information about the systemd-devel mailing list