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
This commit is contained in:
parent
26dac111f1
commit
dd92980bbd
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user