summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authoreivind <eivind@FreeBSD.org>2000-10-29 09:57:50 +0000
committereivind <eivind@FreeBSD.org>2000-10-29 09:57:50 +0000
commit6f8edb50c6d8904d12219526a9ccc789f8a782fb (patch)
tree1cd8de68787755af69e70fd406807ee3654dd56c /usr.sbin
parente96f5ed9b3717ccf4dcca29937101d43ffe25d1c (diff)
downloadFreeBSD-src-6f8edb50c6d8904d12219526a9ccc789f8a782fb.zip
FreeBSD-src-6f8edb50c6d8904d12219526a9ccc789f8a782fb.tar.gz
Teach sysinstall how to restart itself on Ctrl-C (as an addition to its old
tricks of rebooting and continuing where it was.) Reviewed by: jkh, jhb
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/sade/main.c5
-rw-r--r--usr.sbin/sade/sade.h1
-rw-r--r--usr.sbin/sade/system.c52
-rw-r--r--usr.sbin/sysinstall/main.c5
-rw-r--r--usr.sbin/sysinstall/sysinstall.h1
-rw-r--r--usr.sbin/sysinstall/system.c52
6 files changed, 108 insertions, 8 deletions
diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c
index d16720d..e48d6c5 100644
--- a/usr.sbin/sade/main.c
+++ b/usr.sbin/sade/main.c
@@ -38,6 +38,8 @@
#include <sys/signal.h>
#include <sys/fcntl.h>
+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 048a5e7..8dab491 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 0eec38a..1423405 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 d16720d..e48d6c5 100644
--- a/usr.sbin/sysinstall/main.c
+++ b/usr.sbin/sysinstall/main.c
@@ -38,6 +38,8 @@
#include <sys/signal.h>
#include <sys/fcntl.h>
+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 048a5e7..8dab491 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 0eec38a..1423405 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);
}
OpenPOWER on IntegriCloud