aboutsummaryrefslogtreecommitdiff
path: root/ltrace.c
diff options
context:
space:
mode:
authorJuan Cespedes <cespedes@debian.org>2003-02-01 19:02:37 +0100
committerJuan Cespedes <cespedes@debian.org>2003-02-01 19:02:37 +0100
commita0ccf39a68c0fcdf2165bde0f9b70ed12fc61cd8 (patch)
treeafe23bec662ac61ab1a8c1bdb6463c3c017f775b /ltrace.c
parent7186e2af704f4458e6383e8a92482594db29b597 (diff)
downloadltrace-a0ccf39a68c0fcdf2165bde0f9b70ed12fc61cd8.tar.gz
Version 0.3.29
* Align return values depending on screen width * Updated list of syscalls and signals to Linux 2.4.20 * Fixed bug introduced in 0.3.27 which caused -L option to segfault
Diffstat (limited to 'ltrace.c')
-rw-r--r--ltrace.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ltrace.c b/ltrace.c
index fbd6ca4..461e745 100644
--- a/ltrace.c
+++ b/ltrace.c
@@ -10,6 +10,7 @@
#include <sys/param.h>
#include <signal.h>
#include <sys/wait.h>
+#include <sys/ioctl.h>
#include "ltrace.h"
#include "output.h"
@@ -72,6 +73,25 @@ normal_exit(void) {
output_line(0,0);
}
+static void
+guess_cols(void) {
+ struct winsize ws;
+ char * c;
+
+ opt_a = DEFAULT_ACOLUMN;
+ c = getenv("COLUMNS");
+ if (c && *c) {
+ char * endptr;
+ int cols;
+ cols = strtol(c, &endptr, 0);
+ if (cols>0 && !*endptr) {
+ opt_a = cols * 5/8;
+ }
+ } else if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col>0) {
+ opt_a = ws.ws_col * 5/8;
+ }
+}
+
int
main(int argc, char **argv) {
struct opt_p_t * opt_p_tmp;
@@ -81,6 +101,7 @@ main(int argc, char **argv) {
signal(SIGINT,signal_exit); /* Detach processes when interrupted */
signal(SIGTERM,signal_exit); /* ... or killed */
+ guess_cols();
argv = process_options(argc, argv);
read_config_file(SYSCONFDIR "/ltrace.conf");
home = getenv("HOME");