watch -g exits early
Patch supplied by Kent R. Spillner <kspillner@acm.org>. Previous watch -g would do the following: unchanged screen (wait) changed screen (wait) (exit) Now it exits right after the screen changes.
This commit is contained in:
parent
2323f864f3
commit
ce82c3ea37
10
watch.c
10
watch.c
@ -308,7 +308,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
int pipefd[2];
|
int pipefd[2];
|
||||||
int status;
|
int status;
|
||||||
int exit_early = 0;
|
|
||||||
pid_t child;
|
pid_t child;
|
||||||
|
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
@ -446,7 +445,7 @@ int main(int argc, char *argv[])
|
|||||||
if (precise_timekeeping)
|
if (precise_timekeeping)
|
||||||
next_loop = get_time_usec();
|
next_loop = get_time_usec();
|
||||||
|
|
||||||
do {
|
while (1) {
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
char *ts = ctime(&t);
|
char *ts = ctime(&t);
|
||||||
int tsl = strlen(ts);
|
int tsl = strlen(ts);
|
||||||
@ -581,6 +580,7 @@ int main(int argc, char *argv[])
|
|||||||
if ((p = fdopen(pipefd[0], "r")) == NULL)
|
if ((p = fdopen(pipefd[0], "r")) == NULL)
|
||||||
xerr(5, _("fdopen"));
|
xerr(5, _("fdopen"));
|
||||||
|
|
||||||
|
int exit_early = 0;
|
||||||
for (y = show_title; y < height; y++) {
|
for (y = show_title; y < height; y++) {
|
||||||
int eolseen = 0, tabpending = 0;
|
int eolseen = 0, tabpending = 0;
|
||||||
#ifdef WITH_WATCH8BIT
|
#ifdef WITH_WATCH8BIT
|
||||||
@ -730,6 +730,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
first_screen = 0;
|
first_screen = 0;
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
if (exit_early)
|
||||||
|
break;
|
||||||
|
|
||||||
if (precise_timekeeping) {
|
if (precise_timekeeping) {
|
||||||
watch_usec_t cur_time = get_time_usec();
|
watch_usec_t cur_time = get_time_usec();
|
||||||
next_loop += USECS_PER_SEC * interval;
|
next_loop += USECS_PER_SEC * interval;
|
||||||
@ -737,7 +741,7 @@ int main(int argc, char *argv[])
|
|||||||
usleep(next_loop - cur_time);
|
usleep(next_loop - cur_time);
|
||||||
} else
|
} else
|
||||||
usleep(interval * 1000000);
|
usleep(interval * 1000000);
|
||||||
} while (!exit_early);
|
}
|
||||||
|
|
||||||
endwin();
|
endwin();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user