diff --git a/release/sysinstall/main.c b/release/sysinstall/main.c index d16720d981fc..e48d6c534e49 100644 --- a/release/sysinstall/main.c +++ b/release/sysinstall/main.c @@ -38,6 +38,8 @@ #include #include +const char *StartName; /* Initial contents of argv[0] */ + static void screech(int sig) { @@ -49,6 +51,9 @@ int main(int argc, char **argv) { int choice, scroll, curr, max, status; + + /* Record name to be able to restart */ + StartName = argv[0]; /* Catch fatal signals and complain about them if running as init */ if (getpid() == 1) { diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index 048a5e7c4f5d..8dab491f23ca 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/sysinstall/sysinstall.h @@ -403,6 +403,7 @@ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ extern DMenu MenuXF86Config; /* Select XFree86 configuration type */ extern int FixItMode; /* FixItMode starts shell onc urrent device (ie Serial port) */ +extern const char * StartName; /* Which name we were started as */ /* Stuff from libdialog which isn't properly declared outside */ extern void display_helpfile(void); diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c index 0eec38aa48f6..14234058c581 100644 --- a/release/sysinstall/system.c +++ b/release/sysinstall/system.c @@ -39,15 +39,50 @@ static pid_t ehs_pid; * due to our having bogotified the internal state of dialog or curses, * but we'll give it a try. */ +static int +intr_continue(dialogMenuItem *self) +{ + return DITEM_LEAVE_MENU; +} + +static int +intr_reboot(dialogMenuItem *self) +{ + systemShutdown(-1); + /* NOTREACHED */ + return 0; +} + +static int +intr_restart(dialogMenuItem *self) +{ + execl(StartName, StartName, NULL); + /* NOTREACHED */ + return -1; +} + +static dialogMenuItem intrmenu[] = { + { "Abort", "Abort the installation", NULL, intr_reboot }, + { "Restart", "Restart the installation program", NULL, intr_restart }, + { "Continue", "Continue the installation", NULL, intr_continue }, +}; + + static void handle_intr(int sig) { WINDOW *save = savescr(); - if (!msgYesNo("Are you sure you want to abort the installation?")) - systemShutdown(-1); - else - restorescr(save); + use_helpline(NULL); + use_helpfile(NULL); + if (OnVTY) { + ioctl(0, VT_ACTIVATE, 1); /* Switch back */ + msgInfo(NULL); + } + (void)dialog_menu("Installation interrupt", + "Do you want to abort the installation?", + -1, -1, 3, -3, intrmenu, NULL, NULL, NULL); + restorescr(save); } /* Expand a file into a convenient location, nuking it each time */ @@ -75,6 +110,7 @@ void systemInitialize(int argc, char **argv) { int i, boothowto; + sigset_t signalset; signal(SIGINT, SIG_IGN); globalsInit(); @@ -150,6 +186,14 @@ systemInitialize(int argc, char **argv) if (!getenv("HOME")) setenv("HOME", "/", 1); signal(SIGINT, handle_intr); + /* + * Make sure we can be interrupted even if we were re-executed + * from an interrupt. + */ + sigemptyset(&signalset); + sigaddset(&signalset, SIGINT); + sigprocmask(SIG_UNBLOCK, &signalset, NULL); + (void)vsystem("rm -rf %s", DOC_TMP_DIR); } diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c index d16720d981fc..e48d6c534e49 100644 --- a/usr.sbin/sade/main.c +++ b/usr.sbin/sade/main.c @@ -38,6 +38,8 @@ #include #include +const char *StartName; /* Initial contents of argv[0] */ + static void screech(int sig) { @@ -49,6 +51,9 @@ int main(int argc, char **argv) { int choice, scroll, curr, max, status; + + /* Record name to be able to restart */ + StartName = argv[0]; /* Catch fatal signals and complain about them if running as init */ if (getpid() == 1) { diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index 048a5e7c4f5d..8dab491f23ca 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -403,6 +403,7 @@ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ extern DMenu MenuXF86Config; /* Select XFree86 configuration type */ extern int FixItMode; /* FixItMode starts shell onc urrent device (ie Serial port) */ +extern const char * StartName; /* Which name we were started as */ /* Stuff from libdialog which isn't properly declared outside */ extern void display_helpfile(void); diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index 0eec38aa48f6..14234058c581 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/system.c @@ -39,15 +39,50 @@ static pid_t ehs_pid; * due to our having bogotified the internal state of dialog or curses, * but we'll give it a try. */ +static int +intr_continue(dialogMenuItem *self) +{ + return DITEM_LEAVE_MENU; +} + +static int +intr_reboot(dialogMenuItem *self) +{ + systemShutdown(-1); + /* NOTREACHED */ + return 0; +} + +static int +intr_restart(dialogMenuItem *self) +{ + execl(StartName, StartName, NULL); + /* NOTREACHED */ + return -1; +} + +static dialogMenuItem intrmenu[] = { + { "Abort", "Abort the installation", NULL, intr_reboot }, + { "Restart", "Restart the installation program", NULL, intr_restart }, + { "Continue", "Continue the installation", NULL, intr_continue }, +}; + + static void handle_intr(int sig) { WINDOW *save = savescr(); - if (!msgYesNo("Are you sure you want to abort the installation?")) - systemShutdown(-1); - else - restorescr(save); + use_helpline(NULL); + use_helpfile(NULL); + if (OnVTY) { + ioctl(0, VT_ACTIVATE, 1); /* Switch back */ + msgInfo(NULL); + } + (void)dialog_menu("Installation interrupt", + "Do you want to abort the installation?", + -1, -1, 3, -3, intrmenu, NULL, NULL, NULL); + restorescr(save); } /* Expand a file into a convenient location, nuking it each time */ @@ -75,6 +110,7 @@ void systemInitialize(int argc, char **argv) { int i, boothowto; + sigset_t signalset; signal(SIGINT, SIG_IGN); globalsInit(); @@ -150,6 +186,14 @@ systemInitialize(int argc, char **argv) if (!getenv("HOME")) setenv("HOME", "/", 1); signal(SIGINT, handle_intr); + /* + * Make sure we can be interrupted even if we were re-executed + * from an interrupt. + */ + sigemptyset(&signalset); + sigaddset(&signalset, SIGINT); + sigprocmask(SIG_UNBLOCK, &signalset, NULL); + (void)vsystem("rm -rf %s", DOC_TMP_DIR); } diff --git a/usr.sbin/sysinstall/main.c b/usr.sbin/sysinstall/main.c index d16720d981fc..e48d6c534e49 100644 --- a/usr.sbin/sysinstall/main.c +++ b/usr.sbin/sysinstall/main.c @@ -38,6 +38,8 @@ #include #include +const char *StartName; /* Initial contents of argv[0] */ + static void screech(int sig) { @@ -49,6 +51,9 @@ int main(int argc, char **argv) { int choice, scroll, curr, max, status; + + /* Record name to be able to restart */ + StartName = argv[0]; /* Catch fatal signals and complain about them if running as init */ if (getpid() == 1) { diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index 048a5e7c4f5d..8dab491f23ca 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -403,6 +403,7 @@ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ extern DMenu MenuXF86Config; /* Select XFree86 configuration type */ extern int FixItMode; /* FixItMode starts shell onc urrent device (ie Serial port) */ +extern const char * StartName; /* Which name we were started as */ /* Stuff from libdialog which isn't properly declared outside */ extern void display_helpfile(void); diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index 0eec38aa48f6..14234058c581 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -39,15 +39,50 @@ static pid_t ehs_pid; * due to our having bogotified the internal state of dialog or curses, * but we'll give it a try. */ +static int +intr_continue(dialogMenuItem *self) +{ + return DITEM_LEAVE_MENU; +} + +static int +intr_reboot(dialogMenuItem *self) +{ + systemShutdown(-1); + /* NOTREACHED */ + return 0; +} + +static int +intr_restart(dialogMenuItem *self) +{ + execl(StartName, StartName, NULL); + /* NOTREACHED */ + return -1; +} + +static dialogMenuItem intrmenu[] = { + { "Abort", "Abort the installation", NULL, intr_reboot }, + { "Restart", "Restart the installation program", NULL, intr_restart }, + { "Continue", "Continue the installation", NULL, intr_continue }, +}; + + static void handle_intr(int sig) { WINDOW *save = savescr(); - if (!msgYesNo("Are you sure you want to abort the installation?")) - systemShutdown(-1); - else - restorescr(save); + use_helpline(NULL); + use_helpfile(NULL); + if (OnVTY) { + ioctl(0, VT_ACTIVATE, 1); /* Switch back */ + msgInfo(NULL); + } + (void)dialog_menu("Installation interrupt", + "Do you want to abort the installation?", + -1, -1, 3, -3, intrmenu, NULL, NULL, NULL); + restorescr(save); } /* Expand a file into a convenient location, nuking it each time */ @@ -75,6 +110,7 @@ void systemInitialize(int argc, char **argv) { int i, boothowto; + sigset_t signalset; signal(SIGINT, SIG_IGN); globalsInit(); @@ -150,6 +186,14 @@ systemInitialize(int argc, char **argv) if (!getenv("HOME")) setenv("HOME", "/", 1); signal(SIGINT, handle_intr); + /* + * Make sure we can be interrupted even if we were re-executed + * from an interrupt. + */ + sigemptyset(&signalset); + sigaddset(&signalset, SIGINT); + sigprocmask(SIG_UNBLOCK, &signalset, NULL); + (void)vsystem("rm -rf %s", DOC_TMP_DIR); }