summaryrefslogtreecommitdiffstats
path: root/lib/libvgl/main.c
diff options
context:
space:
mode:
authoryokota <yokota@FreeBSD.org>2001-07-24 11:15:20 +0000
committeryokota <yokota@FreeBSD.org>2001-07-24 11:15:20 +0000
commitbd11ff6285c2f957712b5459af19436d60e5736a (patch)
tree2e95b7e1cb18d2be3e9263e665386e4230e549e9 /lib/libvgl/main.c
parent1b8c225dc1ac21d35188a888a5786c95a353780f (diff)
downloadFreeBSD-src-bd11ff6285c2f957712b5459af19436d60e5736a.zip
FreeBSD-src-bd11ff6285c2f957712b5459af19436d60e5736a.tar.gz
- Do not call VGLEnd() and exit() to terminate the program
immediately when a signal is caught. Instead, defer program termination until the next call to VGLCheckSwitch(). Otherwise, the video card may not be restored correctly if the signal is seen while inside libvgl functions. MFC after: 1 week
Diffstat (limited to 'lib/libvgl/main.c')
-rw-r--r--lib/libvgl/main.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/libvgl/main.c b/lib/libvgl/main.c
index 6522230..5da2047 100644
--- a/lib/libvgl/main.c
+++ b/lib/libvgl/main.c
@@ -54,6 +54,7 @@ static int VGLOldMode;
static size_t VGLBufSize;
static byte *VGLMem = MAP_FAILED;
static int VGLSwitchPending;
+static int VGLAbortPending;
static int VGLOnDisplay;
static unsigned int VGLCurWindow;
static int VGLInitDone = 0;
@@ -67,6 +68,8 @@ struct vt_mode smode;
if (!VGLInitDone)
return;
VGLInitDone = 0;
+ VGLSwitchPending = 0;
+ VGLAbortPending = 0;
signal(SIGUSR1, SIG_IGN);
@@ -103,8 +106,12 @@ struct vt_mode smode;
static void
VGLAbort()
{
- VGLEnd();
- exit(0);
+ VGLAbortPending = 1;
+ signal(SIGINT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ signal(SIGSEGV, SIG_IGN);
+ signal(SIGBUS, SIG_IGN);
+ signal(SIGUSR2, SIG_IGN);
}
static void
@@ -132,9 +139,11 @@ VGLInit(int mode)
signal(SIGTERM, VGLAbort);
signal(SIGSEGV, VGLAbort);
signal(SIGBUS, VGLAbort);
+ signal(SIGUSR2, SIG_IGN);
VGLOnDisplay = 1;
VGLSwitchPending = 0;
+ VGLAbortPending = 0;
if (ioctl(0, CONS_GET, &VGLOldMode) || ioctl(0, CONS_CURRENT, &adptype))
return -1;
@@ -322,6 +331,10 @@ VGLInit(int mode)
void
VGLCheckSwitch()
{
+ if (VGLAbortPending) {
+ VGLEnd();
+ exit(0);
+ }
while (VGLSwitchPending) {
unsigned int offset;
unsigned int len;
OpenPOWER on IntegriCloud