- 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
This commit is contained in:
Kazutaka YOKOTA 2001-07-24 11:15:20 +00:00
parent b2b50712a6
commit 16fc634b67

View File

@ -54,6 +54,7 @@ static int VGLOldMode;
static size_t VGLBufSize; static size_t VGLBufSize;
static byte *VGLMem = MAP_FAILED; static byte *VGLMem = MAP_FAILED;
static int VGLSwitchPending; static int VGLSwitchPending;
static int VGLAbortPending;
static int VGLOnDisplay; static int VGLOnDisplay;
static unsigned int VGLCurWindow; static unsigned int VGLCurWindow;
static int VGLInitDone = 0; static int VGLInitDone = 0;
@ -67,6 +68,8 @@ struct vt_mode smode;
if (!VGLInitDone) if (!VGLInitDone)
return; return;
VGLInitDone = 0; VGLInitDone = 0;
VGLSwitchPending = 0;
VGLAbortPending = 0;
signal(SIGUSR1, SIG_IGN); signal(SIGUSR1, SIG_IGN);
@ -103,8 +106,12 @@ struct vt_mode smode;
static void static void
VGLAbort() VGLAbort()
{ {
VGLEnd(); VGLAbortPending = 1;
exit(0); signal(SIGINT, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGSEGV, SIG_IGN);
signal(SIGBUS, SIG_IGN);
signal(SIGUSR2, SIG_IGN);
} }
static void static void
@ -132,9 +139,11 @@ VGLInit(int mode)
signal(SIGTERM, VGLAbort); signal(SIGTERM, VGLAbort);
signal(SIGSEGV, VGLAbort); signal(SIGSEGV, VGLAbort);
signal(SIGBUS, VGLAbort); signal(SIGBUS, VGLAbort);
signal(SIGUSR2, SIG_IGN);
VGLOnDisplay = 1; VGLOnDisplay = 1;
VGLSwitchPending = 0; VGLSwitchPending = 0;
VGLAbortPending = 0;
if (ioctl(0, CONS_GET, &VGLOldMode) || ioctl(0, CONS_CURRENT, &adptype)) if (ioctl(0, CONS_GET, &VGLOldMode) || ioctl(0, CONS_CURRENT, &adptype))
return -1; return -1;
@ -322,6 +331,10 @@ VGLInit(int mode)
void void
VGLCheckSwitch() VGLCheckSwitch()
{ {
if (VGLAbortPending) {
VGLEnd();
exit(0);
}
while (VGLSwitchPending) { while (VGLSwitchPending) {
unsigned int offset; unsigned int offset;
unsigned int len; unsigned int len;