Beispiel #1
0
static RETSIGTYPE actOnSignal(int signo)
{
    char *signame, buf[32];
     
    installSignal();
    
    switch (signo) {
#ifdef SIGHUP
    case SIGHUP:
    	rereadConfig(gapp);
    	break;
#endif
#ifdef SIGINT
    case SIGINT:
#endif
#ifdef SIGQUIT
    case SIGQUIT:
#endif
#ifdef SIGTERM
    case SIGTERM:
#endif
        bailout(gapp);
        break;
#ifdef SIGILL
    case SIGILL:
        signame = "SIGILL";
#endif
#ifdef SIGFPE
    case SIGFPE:
        signame = "SIGFPE";
#endif
#ifdef SIGBUS
    case SIGBUS:
        signame = "SIGBUS";
#endif
#ifdef SIGSEGV
    case SIGSEGV:
        signame = "SIGSEGV";
#endif
#ifdef SIGSYS
    case SIGSYS:
        signame = "SIGSYS";
#endif
        sprintf(buf, "Got fatal signal %s!", signame);
        emergency_exit(gapp, TRUE, buf);
        break;
    default:
        /* ignore the rest */
        break;
    }
}
Beispiel #2
0
/*
 * Interrupt handler for X IO errors
 */
static int HandleXIOError(Display *d)
{
    char msg[BUFSIZE];      
    if (errno == EPIPE) {
        sprintf(msg, "X connection to %s broken (server error - EPIPE).",
               DisplayString(d));
    } else {
        sprintf(msg, "Fatal IO error on X server %s.", DisplayString(d));
    }

    emergency_exit(gapp, FALSE, msg);
    
    /* Ideally, we don't reach this anyway ... */
    return 1;
}
Beispiel #3
0
static int HandleXError(Display *dpy, XErrorEvent *event)
{
    char buffer[BUFSIZE], mesg[BUFSIZE], *output;

    char *mtype = "XlibMessage";

    XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", buffer, BUFSIZE);
    output = copy_string(NULL, buffer);
    output = concat_strings(output, ":");
    
    XGetErrorText(dpy, event->error_code, buffer, BUFSIZE);
    output = concat_strings(output, buffer);
    output = concat_strings(output, "\n");
    
    XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg,
                          BUFSIZE);
    sprintf(buffer, mesg, event->request_code);
    output = concat_strings(output, buffer);

    if (event->request_code < 128) {
        char number[32];
        sprintf(number, "%d", event->request_code);
        XGetErrorDatabaseText(dpy, "XRequest", number, "", mesg, BUFSIZE);
        sprintf(buffer, " (%s)\n", mesg);
        output = concat_strings(output, buffer);
    }

    switch (event->error_code) {
    case (BadWindow):
    case (BadPixmap):
    case (BadCursor):
    case (BadFont):
    case (BadDrawable):
    case (BadColor):
    case (BadGC):
    case (BadIDChoice):
    case (BadValue):
    case (BadAtom):
        if (event->error_code == BadValue) {
           XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", mesg,
                                 BUFSIZE);
        } else if (event->error_code == BadAtom) {
           XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", mesg,
                                 BUFSIZE);
        } else {
           XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
                                 mesg, BUFSIZE);
        }
        output = concat_strings(output, "  ");
        sprintf(buffer, mesg, event->resourceid);
        output = concat_strings(output, buffer);
        output = concat_strings(output, "\n");
        break;
    } /* switch() */

    XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", mesg,
                           BUFSIZE);
    sprintf(buffer, mesg, event->serial);
    output = concat_strings(output, "  ");
    output = concat_strings(output, buffer);
    output = concat_strings(output, ".");
    
    emergency_exit(gapp, TRUE, output);
    xfree(output);
    
    /* return value is ignored anyway */
    return 0;
}