]> granicus.if.org Git - procps-ng/commitdiff
watch: exit cleanly when falling through main loop.
authorKent R. Spillner <kspillner@acm.org>
Sun, 11 Mar 2012 00:35:08 +0000 (18:35 -0600)
committerKent R. Spillner <kspillner@acm.org>
Sun, 11 Mar 2012 00:35:08 +0000 (18:35 -0600)
Revert commit ffe5e0b08eb981b862bab8220f0b9fcf48b7fc4f.  Restores
clean exit when falling through main loop.

Previously, watch only exited when there was an error or when
interrupted by the user.  Commit 81f64657ba183ee983ea98c7f97904296b2ce5aa
added another exit condition when the watched command's output
changes, causing execution to fall out of the main loop.

With this change, watch correctly restores the terminal and returns
an exit code indicating success when invoked with the --chgexit/-g
options.

watch.c

diff --git a/watch.c b/watch.c
index e9ce7c013b4f2f8c2eb1cc0e4e430f2458903141..e3066f6ffcb68bc896068cad0895fe9a321a39c7 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -739,5 +739,7 @@ int main(int argc, char *argv[])
                        usleep(interval * 1000000);
        } while (!exit_early);
 
-       return EXIT_FAILURE;
+       endwin();
+
+       return EXIT_SUCCESS;
 }