aboutsummaryrefslogtreecommitdiff
path: root/procps/watch.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-09 08:27:24 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-09 08:27:24 +0000
commitf893da875a24138fac30f070c7101b5330f0fef0 (patch)
treeede441ba82f7a1bf9942ba33a64e91bcd8173920 /procps/watch.c
parent501bfe2630054f9988e08a5d77e1b1ff2abc78bb (diff)
downloadbusybox-f893da875a24138fac30f070c7101b5330f0fef0.tar.gz
ls,ps,watch: measure terminal width on fd 0, not 1
Diffstat (limited to 'procps/watch.c')
-rw-r--r--procps/watch.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/procps/watch.c b/procps/watch.c
index 2ad0564cd..b2adcd5ce 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -28,7 +28,7 @@ int watch_main(int argc, char **argv)
{
unsigned opt;
unsigned period = 2;
- unsigned cmdlen = 1; // 1 for terminal NUL
+ unsigned cmdlen;
char *header = NULL;
char *cmd;
char *tmp;
@@ -42,6 +42,7 @@ int watch_main(int argc, char **argv)
argv += optind;
p = argv;
+ cmdlen = 1; // 1 for terminal NUL
while (*p)
cmdlen += strlen(*p++) + 1;
tmp = cmd = xmalloc(cmdlen);
@@ -58,7 +59,7 @@ int watch_main(int argc, char **argv)
char *thyme;
time_t t;
- get_terminal_width_height(STDOUT_FILENO, &width, 0);
+ get_terminal_width_height(STDIN_FILENO, &width, 0);
header = xrealloc(header, width--);
// '%-*s' pads header with spaces to the full width
snprintf(header, width, "Every %ds: %-*s", period, width, cmd);