summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-11-01 15:28:41 -0800
committerH. Peter Anvin <hpa@zytor.com>2006-11-01 15:28:41 -0800
commit2dd31c890274efffe32448f596522108a5bfc4ac (patch)
tree365a337b13a02b7d69dfadeacb83fce3482b7132
parent3a7064b4b9c098e4e5aac6396a83c86f9c8f08cd (diff)
downloadsyslinux-2dd31c890274efffe32448f596522108a5bfc4ac.tar.gz
menu system: handle console setup/cleanup differently
Handle console setup/cleanup explicitly, instead of relying on a destructor. The destructor doesn't get called on outbound API calls that don't return.
-rw-r--r--com32/modules/menu.c10
-rw-r--r--com32/modules/menu.h2
-rw-r--r--com32/modules/menumain.c6
-rw-r--r--com32/modules/vesamenu.c8
4 files changed, 24 insertions, 2 deletions
diff --git a/com32/modules/menu.c b/com32/modules/menu.c
index b7338641..1f2c5103 100644
--- a/com32/modules/menu.c
+++ b/com32/modules/menu.c
@@ -20,6 +20,16 @@
#include <consoles.h>
#include "menu.h"
+void console_prepare(void)
+{
+ /* Nothing special to do */
+}
+
+void console_cleanup(void)
+{
+ /* Nothing special to do */
+}
+
int main(int argc, char *argv[])
{
console_ansi_raw();
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index e856977c..a70ba925 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -74,5 +74,7 @@ static inline int my_isspace(char c)
}
int menu_main(int argc, char *argv[]);
+void console_prepare(void);
+void console_cleanup(void);
#endif /* MENU_H */
diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c
index d0c02436..9d33babb 100644
--- a/com32/modules/menumain.c
+++ b/com32/modules/menumain.c
@@ -848,6 +848,8 @@ int menu_main(int argc, char *argv[])
(void)argc;
+ console_prepare();
+
install_default_color_table();
if (getscreensize(1, &rows, &cols)) {
/* Unknown screen size? */
@@ -876,6 +878,8 @@ int menu_main(int argc, char *argv[])
cmdline = run_menu();
printf("\033[?25h\033[%d;1H\033[0m", END_ROW);
+ console_cleanup();
+
if ( cmdline ) {
execute(cmdline);
if ( onerror )
@@ -883,5 +887,7 @@ int menu_main(int argc, char *argv[])
} else {
return 0; /* Exit */
}
+
+ console_prepare(); /* If we're looping... */
}
}
diff --git a/com32/modules/vesamenu.c b/com32/modules/vesamenu.c
index 88fe78d5..6316eae4 100644
--- a/com32/modules/vesamenu.c
+++ b/com32/modules/vesamenu.c
@@ -23,7 +23,12 @@
#include <console.h>
#include "menu.h"
-static void __attribute__((destructor)) console_cleanup(void)
+void console_prepare(void)
+{
+ fputs("\033[0m\033[20h\033[25l", stdout);
+}
+
+void console_cleanup(void)
{
/* For the serial console, be nice and clean up */
fputs("\033[0m\033[20l", stdout);
@@ -34,7 +39,6 @@ int vesacon_load_background(const char *);
int main(int argc, char *argv[])
{
openconsole(&dev_rawcon_r, &dev_vesaserial_w);
- fputs("\033[0m\033[20h\033[25l", stdout);
draw_background = vesacon_load_background;