ia64/xen-unstable
changeset 11857:c6a65f481538
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>
older libcurses implementations.
Signed-off-by: John Levon <john.levon@sun.com>
author | kfraser@localhost.localdomain |
---|---|
date | Tue Oct 17 18:36:26 2006 +0100 (2006-10-17) |
parents | 9754c40fc673 |
children | c4cc70c32077 |
files | tools/xenstat/xentop/xentop.c |
line diff
1.1 --- a/tools/xenstat/xentop/xentop.c Tue Oct 17 18:35:13 2006 +0100 1.2 +++ b/tools/xenstat/xentop/xentop.c Tue Oct 17 18:36:26 2006 +0100 1.3 @@ -187,6 +187,8 @@ char prompt_val[PROMPT_VAL_LEN]; 1.4 int prompt_val_len = 0; 1.5 void (*prompt_complete_func)(char *); 1.6 1.7 +static WINDOW *cwin; 1.8 + 1.9 /* 1.10 * Function definitions 1.11 */ 1.12 @@ -223,7 +225,7 @@ static void version(void) 1.13 /* Clean up any open resources */ 1.14 static void cleanup(void) 1.15 { 1.16 - if(!isendwin()) 1.17 + if(cwin != NULL && !isendwin()) 1.18 endwin(); 1.19 if(prev_node != NULL) 1.20 xenstat_free_node(prev_node); 1.21 @@ -236,7 +238,7 @@ static void cleanup(void) 1.22 /* Display the given message and gracefully exit */ 1.23 static void fail(const char *str) 1.24 { 1.25 - if(!isendwin()) 1.26 + if(cwin != NULL && !isendwin()) 1.27 endwin(); 1.28 fprintf(stderr, str); 1.29 exit(1); 1.30 @@ -1029,7 +1031,7 @@ int main(int argc, char **argv) 1.31 1.32 if (!batch) { 1.33 /* Begin curses stuff */ 1.34 - initscr(); 1.35 + cwin = initscr(); 1.36 start_color(); 1.37 cbreak(); 1.38 noecho();