diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-10-17 18:36:26 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2006-10-17 18:36:26 +0100 |
commit | afe801a3be7876408534f48b21e7e11a799ddf0d (patch) | |
tree | f31799b8ea9f289181edaba566e4c3f4c5aca125 /tools/xenstat/xentop | |
parent | 7b7b7c2feffe2ae844a5691665000d085d938c3a (diff) | |
download | xen-afe801a3be7876408534f48b21e7e11a799ddf0d.tar.gz xen-afe801a3be7876408534f48b21e7e11a799ddf0d.tar.bz2 xen-afe801a3be7876408534f48b21e7e11a799ddf0d.zip |
It's not correct to call endwin() if initscr() fails, and it crashes
older libcurses implementations.
Signed-off-by: John Levon <john.levon@sun.com>
Diffstat (limited to 'tools/xenstat/xentop')
-rw-r--r-- | tools/xenstat/xentop/xentop.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c index 271f4b2bf7..7d3ec59d2e 100644 --- a/tools/xenstat/xentop/xentop.c +++ b/tools/xenstat/xentop/xentop.c @@ -187,6 +187,8 @@ char prompt_val[PROMPT_VAL_LEN]; int prompt_val_len = 0; void (*prompt_complete_func)(char *); +static WINDOW *cwin; + /* * Function definitions */ @@ -223,7 +225,7 @@ static void version(void) /* Clean up any open resources */ static void cleanup(void) { - if(!isendwin()) + if(cwin != NULL && !isendwin()) endwin(); if(prev_node != NULL) xenstat_free_node(prev_node); @@ -236,7 +238,7 @@ static void cleanup(void) /* Display the given message and gracefully exit */ static void fail(const char *str) { - if(!isendwin()) + if(cwin != NULL && !isendwin()) endwin(); fprintf(stderr, str); exit(1); @@ -1029,7 +1031,7 @@ int main(int argc, char **argv) if (!batch) { /* Begin curses stuff */ - initscr(); + cwin = initscr(); start_color(); cbreak(); noecho(); |