summaryrefslogtreecommitdiff
path: root/src/pacman/pacman.c
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2014-06-21 08:44:01 -0400
committerAllan McRae <allan@archlinux.org>2014-06-29 11:04:17 +1000
commit357b9a24a96478b7bcaaea8633f8f6a519f8903c (patch)
tree28cdc687d3a12ab389d36758e828d17c1c13dde5 /src/pacman/pacman.c
parent07647d3d43d418f9efcf7c83a2079b9b673a7bfa (diff)
downloadpacman-357b9a24a96478b7bcaaea8633f8f6a519f8903c.tar.xz
cache terminal size, add SIGWINCH handler to reset
Refactoring getcols, yet again. We do the following: 1) Introduce a static global in src/pacman/util.c 2) getcols always prefers this cached value, but will derive it from the COLUMNS environment var, the characteristics of stdout, or a sane default (in that order). 3) Introduce a SIGWINCH signal handler to reset the cached value, meaning we only call ioctl when we don't know the value. On my machine, pacman -Syy goes from ~4300 ioctl calls to 3.
Diffstat (limited to 'src/pacman/pacman.c')
-rw-r--r--src/pacman/pacman.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index baa0485b..12a4f7a3 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -312,6 +312,9 @@ static void handler(int signum)
/* a transaction is being interrupted, don't exit pacman yet. */
return;
}
+ } else if(signum == SIGWINCH) {
+ columns_cache_reset();
+ return;
}
/* SIGINT/SIGHUP: no committing transaction, release it now and then exit pacman
* SIGTERM: release no matter what */
@@ -1019,7 +1022,7 @@ int main(int argc, char *argv[])
int ret = 0;
size_t i;
struct sigaction new_action, old_action;
- const int signals[] = { SIGHUP, SIGINT, SIGTERM, SIGSEGV };
+ const int signals[] = { SIGHUP, SIGINT, SIGTERM, SIGSEGV, SIGWINCH };
uid_t myuid = getuid();
/* Set signal handlers */