aboutsummaryrefslogtreecommitdiff
path: root/procps/watch.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/watch.c')
-rw-r--r--procps/watch.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/procps/watch.c b/procps/watch.c
index 5b774e808..7d8e0de1f 100644
--- a/procps/watch.c
+++ b/procps/watch.c
@@ -28,7 +28,7 @@ int watch_main(int argc ATTRIBUTE_UNUSED, char **argv)
28{ 28{
29 unsigned opt; 29 unsigned opt;
30 unsigned period = 2; 30 unsigned period = 2;
31 int width, new_width; 31 unsigned width, new_width;
32 char *header; 32 char *header;
33 char *cmd; 33 char *cmd;
34 34
@@ -43,19 +43,19 @@ int watch_main(int argc ATTRIBUTE_UNUSED, char **argv)
43 while (*++argv) 43 while (*++argv)
44 cmd = xasprintf("%s %s", cmd, *argv); // leaks cmd 44 cmd = xasprintf("%s %s", cmd, *argv); // leaks cmd
45 45
46 width = -1; // make sure first time new_width != width 46 width = (unsigned)-1; // make sure first time new_width != width
47 header = NULL; 47 header = NULL;
48 while (1) { 48 while (1) {
49 printf("\033[H\033[J"); 49 printf("\033[H\033[J");
50 if (!(opt & 0x2)) { // no -t 50 if (!(opt & 0x2)) { // no -t
51 const int time_len = sizeof("1234-67-90 23:56:89"); 51 const unsigned time_len = sizeof("1234-67-90 23:56:89");
52 time_t t; 52 time_t t;
53 53
54 get_terminal_width_height(STDIN_FILENO, &new_width, NULL); 54 get_terminal_width_height(STDIN_FILENO, &new_width, NULL);
55 if (new_width != width) { 55 if (new_width != width) {
56 width = new_width; 56 width = new_width;
57 free(header); 57 free(header);
58 header = xasprintf("Every %us: %-*s", period, width, cmd); 58 header = xasprintf("Every %us: %-*s", period, (int)width, cmd);
59 } 59 }
60 time(&t); 60 time(&t);
61 if (time_len < width) 61 if (time_len < width)