Clear blocked signals at startup and exit.
Set EDBUG_COREDUMP to get core dump in stead of GSOD. SVN revision: 10106
This commit is contained in:
parent
b8507d8bac
commit
307e769187
8
src/E.h
8
src/E.h
|
@ -1261,13 +1261,16 @@ typedef struct
|
||||||
char single; /* No slaves */
|
char single; /* No slaves */
|
||||||
pid_t master_pid;
|
pid_t master_pid;
|
||||||
int master_screen;
|
int master_screen;
|
||||||
|
char startup;
|
||||||
|
char xselect;
|
||||||
|
char exiting;
|
||||||
|
char save_ok;
|
||||||
|
char coredump;
|
||||||
} wm;
|
} wm;
|
||||||
int debug;
|
int debug;
|
||||||
int mode;
|
int mode;
|
||||||
char place;
|
char place;
|
||||||
char flipp;
|
char flipp;
|
||||||
char startup;
|
|
||||||
char xselect;
|
|
||||||
int next_move_x_plus, next_move_y_plus;
|
int next_move_x_plus, next_move_y_plus;
|
||||||
Button *button;
|
Button *button;
|
||||||
int resize_detail;
|
int resize_detail;
|
||||||
|
@ -1307,7 +1310,6 @@ typedef struct
|
||||||
int last_button;
|
int last_button;
|
||||||
Time last_time;
|
Time last_time;
|
||||||
char queue_up;
|
char queue_up;
|
||||||
char save_ok;
|
|
||||||
}
|
}
|
||||||
EMode;
|
EMode;
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ runApp(const char *exe, const char *params)
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Mode.startup)
|
if (!Mode.wm.startup)
|
||||||
{
|
{
|
||||||
path = pathtofile(exe);
|
path = pathtofile(exe);
|
||||||
if (!path)
|
if (!path)
|
||||||
|
|
|
@ -441,7 +441,7 @@ AddToFamily(Window win)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!ewin->client.transient) && (Conf.manual_placement)
|
if ((!ewin->client.transient) && (Conf.manual_placement)
|
||||||
&& (!ewin->client.already_placed) && (!Mode.startup) && (!Mode.place))
|
&& (!ewin->client.already_placed) && (!Mode.wm.startup) && (!Mode.place))
|
||||||
{
|
{
|
||||||
cangrab = GrabThePointer(VRoot.win);
|
cangrab = GrabThePointer(VRoot.win);
|
||||||
if ((cangrab == GrabNotViewable) || (cangrab == AlreadyGrabbed)
|
if ((cangrab == GrabNotViewable) || (cangrab == AlreadyGrabbed)
|
||||||
|
@ -1132,7 +1132,8 @@ Adopt(Window win)
|
||||||
SessionGetInfo(ewin, 0);
|
SessionGetInfo(ewin, 0);
|
||||||
MatchEwinToSM(ewin);
|
MatchEwinToSM(ewin);
|
||||||
MatchEwinToSnapInfo(ewin);
|
MatchEwinToSnapInfo(ewin);
|
||||||
ICCCM_GetEInfo(ewin);
|
if (Mode.wm.startup)
|
||||||
|
ICCCM_GetEInfo(ewin);
|
||||||
|
|
||||||
if (!ewin->border)
|
if (!ewin->border)
|
||||||
EwinSetBorderInit(ewin);
|
EwinSetBorderInit(ewin);
|
||||||
|
@ -1226,7 +1227,7 @@ EwinCreate(Window win)
|
||||||
ewin = Emalloc(sizeof(EWin));
|
ewin = Emalloc(sizeof(EWin));
|
||||||
memset(ewin, 0, sizeof(EWin));
|
memset(ewin, 0, sizeof(EWin));
|
||||||
|
|
||||||
ewin->state = (Mode.startup) ? EWIN_STATE_STARTUP : EWIN_STATE_NEW;
|
ewin->state = (Mode.wm.startup) ? EWIN_STATE_STARTUP : EWIN_STATE_NEW;
|
||||||
ewin->x = -1;
|
ewin->x = -1;
|
||||||
ewin->y = -1;
|
ewin->y = -1;
|
||||||
ewin->w = -1;
|
ewin->w = -1;
|
||||||
|
|
|
@ -121,27 +121,53 @@ SignalHandler(int sig)
|
||||||
EDBUG_RETURN_;
|
EDBUG_RETURN_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
doSignalsSetup(int setup)
|
||||||
|
{
|
||||||
|
static const int signals[] = {
|
||||||
|
SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE,
|
||||||
|
SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGCHLD, SIGBUS
|
||||||
|
};
|
||||||
|
unsigned int i, sig;
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We may be here after a fork/exec within in a signal handler.
|
||||||
|
* Therefore, lets just clear the blocked signals.
|
||||||
|
*/
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(signals) / sizeof(int); i++)
|
||||||
|
{
|
||||||
|
sig = signals[i];
|
||||||
|
if (Mode.wm.coredump &&
|
||||||
|
(sig == SIGILL || sig == SIGFPE || sig == SIGSEGV || sig == SIGBUS))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (setup)
|
||||||
|
{
|
||||||
|
sa.sa_handler = SignalHandler;
|
||||||
|
sa.sa_flags = (sig == SIGCHLD) ? SA_RESTART : 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sa.sa_handler = SIG_DFL;
|
||||||
|
sa.sa_flags = 0;
|
||||||
|
}
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sigaction(sig, &sa, (struct sigaction *)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SignalsSetup(void)
|
SignalsSetup(void)
|
||||||
{
|
{
|
||||||
/* This function will set up all the signal handlers for E */
|
/* This function will set up all the signal handlers for E */
|
||||||
|
|
||||||
static const int signals[] = {
|
|
||||||
SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE,
|
|
||||||
SIGALRM, SIGTERM, SIGUSR1, SIGUSR2, SIGCHLD, SIGBUS
|
|
||||||
};
|
|
||||||
unsigned int i;
|
|
||||||
struct sigaction sa;
|
|
||||||
|
|
||||||
EDBUG(6, "SignalsSetup");
|
EDBUG(6, "SignalsSetup");
|
||||||
|
|
||||||
for (i = 0; i < sizeof(signals) / sizeof(int); i++)
|
doSignalsSetup(1);
|
||||||
{
|
|
||||||
sa.sa_handler = SignalHandler;
|
|
||||||
sa.sa_flags = (signals[i] == SIGCHLD) ? SA_RESTART : 0;
|
|
||||||
sigemptyset(&sa.sa_mask);
|
|
||||||
sigaction(signals[i], &sa, (struct sigaction *)0);
|
|
||||||
}
|
|
||||||
|
|
||||||
EDBUG_RETURN_;
|
EDBUG_RETURN_;
|
||||||
}
|
}
|
||||||
|
@ -153,6 +179,7 @@ SignalsRestore(void)
|
||||||
|
|
||||||
EDBUG(6, "SignalsRestore");
|
EDBUG(6, "SignalsRestore");
|
||||||
|
|
||||||
|
#if 0
|
||||||
signal(SIGHUP, SIG_DFL);
|
signal(SIGHUP, SIG_DFL);
|
||||||
signal(SIGINT, SIG_DFL);
|
signal(SIGINT, SIG_DFL);
|
||||||
signal(SIGQUIT, SIG_DFL);
|
signal(SIGQUIT, SIG_DFL);
|
||||||
|
@ -170,6 +197,9 @@ SignalsRestore(void)
|
||||||
signal(SIGTSTP, SIG_DFL);
|
signal(SIGTSTP, SIG_DFL);
|
||||||
#endif
|
#endif
|
||||||
signal(SIGBUS, SIG_IGN);
|
signal(SIGBUS, SIG_IGN);
|
||||||
|
#else
|
||||||
|
doSignalsSetup(0);
|
||||||
|
#endif
|
||||||
|
|
||||||
EDBUG_RETURN_;
|
EDBUG_RETURN_;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +213,7 @@ EHandleXError(Display * d, XErrorEvent * ev)
|
||||||
if ((ev->request_code == X_ChangeWindowAttributes)
|
if ((ev->request_code == X_ChangeWindowAttributes)
|
||||||
&& (ev->error_code == BadAccess))
|
&& (ev->error_code == BadAccess))
|
||||||
{
|
{
|
||||||
if ((!no_overwrite) && (Mode.xselect))
|
if ((!no_overwrite) && (Mode.wm.xselect))
|
||||||
{
|
{
|
||||||
AlertX(_("Another Window Manager is already running"),
|
AlertX(_("Another Window Manager is already running"),
|
||||||
_("OK (edit file)"), "", _("Cancel (do NOT edit)"),
|
_("OK (edit file)"), "", _("Cancel (do NOT edit)"),
|
||||||
|
|
58
src/icccm.c
58
src/icccm.c
|
@ -1173,39 +1173,35 @@ ICCCM_GetEInfo(EWin * ewin)
|
||||||
num = (int)lnum;
|
num = (int)lnum;
|
||||||
if ((num >= 8) && (c))
|
if ((num >= 8) && (c))
|
||||||
{
|
{
|
||||||
if (Mode.startup)
|
ewin->desktop = c[0];
|
||||||
|
ewin->sticky = c[1];
|
||||||
|
ewin->client.x = c[2];
|
||||||
|
ewin->client.y = c[3];
|
||||||
|
ewin->iconified = c[4];
|
||||||
|
ewin->shaded = c[5];
|
||||||
|
if (ewin->sticky)
|
||||||
|
ewin->desktop = -1;
|
||||||
|
if (ewin->iconified)
|
||||||
{
|
{
|
||||||
ewin->desktop = c[0];
|
ewin->client.start_iconified = 1;
|
||||||
ewin->sticky = c[1];
|
ewin->iconified = 0;
|
||||||
ewin->client.x = c[2];
|
|
||||||
ewin->client.y = c[3];
|
|
||||||
ewin->iconified = c[4];
|
|
||||||
ewin->shaded = c[5];
|
|
||||||
if (ewin->sticky)
|
|
||||||
ewin->desktop = -1;
|
|
||||||
if (ewin->iconified)
|
|
||||||
{
|
|
||||||
ewin->client.start_iconified = 1;
|
|
||||||
ewin->iconified = 0;
|
|
||||||
}
|
|
||||||
ewin->client.already_placed = 1;
|
|
||||||
if (num >= 9)
|
|
||||||
{
|
|
||||||
ewin->client.w = c[6];
|
|
||||||
ewin->client.h = c[7];
|
|
||||||
}
|
|
||||||
XFree(c);
|
|
||||||
|
|
||||||
puc = NULL;
|
|
||||||
XGetWindowProperty(disp, ewin->client.win, aa, 0, 0xffff, True,
|
|
||||||
XA_STRING, &a2, &dummy, &lnum, &ldummy, &puc);
|
|
||||||
str = (char *)puc;
|
|
||||||
num = (int)lnum;
|
|
||||||
if ((num > 0) && (str))
|
|
||||||
EwinSetBorderByName(ewin, str, 0);
|
|
||||||
XFree(str);
|
|
||||||
}
|
}
|
||||||
EDBUG_RETURN(1);
|
ewin->client.already_placed = 1;
|
||||||
|
if (num >= 9)
|
||||||
|
{
|
||||||
|
ewin->client.w = c[6];
|
||||||
|
ewin->client.h = c[7];
|
||||||
|
}
|
||||||
|
XFree(c);
|
||||||
|
|
||||||
|
puc = NULL;
|
||||||
|
XGetWindowProperty(disp, ewin->client.win, aa, 0, 0xffff, True,
|
||||||
|
XA_STRING, &a2, &dummy, &lnum, &ldummy, &puc);
|
||||||
|
str = (char *)puc;
|
||||||
|
num = (int)lnum;
|
||||||
|
if ((num > 0) && (str))
|
||||||
|
EwinSetBorderByName(ewin, str, 0);
|
||||||
|
XFree(str);
|
||||||
}
|
}
|
||||||
EDBUG_RETURN(0);
|
EDBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,9 @@ IB_Animate(char iconify, EWin * from, EWin * to)
|
||||||
GC gc;
|
GC gc;
|
||||||
XGCValues gcv;
|
XGCValues gcv;
|
||||||
|
|
||||||
if (Mode.startup)
|
if (Mode.wm.startup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GrabX();
|
GrabX();
|
||||||
spd = 0.00001;
|
spd = 0.00001;
|
||||||
gcv.subwindow_mode = IncludeInferiors;
|
gcv.subwindow_mode = IncludeInferiors;
|
||||||
|
|
13
src/main.c
13
src/main.c
|
@ -64,7 +64,7 @@ main(int argc, char **argv)
|
||||||
/* Init state variable struct */
|
/* Init state variable struct */
|
||||||
memset(&Mode, 0, sizeof(EMode));
|
memset(&Mode, 0, sizeof(EMode));
|
||||||
Mode.mode = MODE_NONE;
|
Mode.mode = MODE_NONE;
|
||||||
Mode.startup = 1;
|
Mode.wm.startup = 1;
|
||||||
|
|
||||||
/* unsetenv("LD_PRELOAD"); */
|
/* unsetenv("LD_PRELOAD"); */
|
||||||
|
|
||||||
|
@ -77,6 +77,9 @@ main(int argc, char **argv)
|
||||||
str = getenv("EDBUG_FLAGS");
|
str = getenv("EDBUG_FLAGS");
|
||||||
if (str)
|
if (str)
|
||||||
EventDebugInit(str);
|
EventDebugInit(str);
|
||||||
|
str = getenv("EDBUG_COREDUMP");
|
||||||
|
if (str)
|
||||||
|
Mode.wm.coredump = 1;
|
||||||
|
|
||||||
EDBUG(1, "main");
|
EDBUG(1, "main");
|
||||||
|
|
||||||
|
@ -313,8 +316,8 @@ main(int argc, char **argv)
|
||||||
ec->inroot = 1;
|
ec->inroot = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mode.startup = 0;
|
Mode.wm.startup = 0;
|
||||||
Mode.save_ok = Mode.wm.master;
|
Mode.wm.save_ok = Mode.wm.master;
|
||||||
/* ok - paranoia - save current settings to disk */
|
/* ok - paranoia - save current settings to disk */
|
||||||
if (VRoot.scr == 0)
|
if (VRoot.scr == 0)
|
||||||
autosave();
|
autosave();
|
||||||
|
@ -368,9 +371,9 @@ main(int argc, char **argv)
|
||||||
if (Mode.firsttime)
|
if (Mode.firsttime)
|
||||||
runDocBrowser();
|
runDocBrowser();
|
||||||
|
|
||||||
Mode.startup = 1;
|
Mode.wm.startup = 1;
|
||||||
SpawnSnappedCmds();
|
SpawnSnappedCmds();
|
||||||
Mode.startup = 0;
|
Mode.wm.startup = 0;
|
||||||
|
|
||||||
ThemeBadDialog();
|
ThemeBadDialog();
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ SaveWindowStates(void)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char s[4096], ss[4096];
|
char s[4096], ss[4096];
|
||||||
|
|
||||||
if (!Mode.save_ok)
|
if (!Mode.wm.save_ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Etmp(s);
|
Etmp(s);
|
||||||
|
@ -426,7 +426,7 @@ MatchEwinToSM(EWin * ewin)
|
||||||
void
|
void
|
||||||
autosave(void)
|
autosave(void)
|
||||||
{
|
{
|
||||||
if (!Mode.save_ok)
|
if (!Mode.wm.save_ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Conf.autosave)
|
if (Conf.autosave)
|
||||||
|
@ -919,9 +919,8 @@ SetSMID(const char *smid)
|
||||||
#endif /* HAVE_X11_SM_SMLIB_H */
|
#endif /* HAVE_X11_SM_SMLIB_H */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doSMExit(const void *params);
|
|
||||||
static void
|
static void
|
||||||
LogoutCB(int val, void *data)
|
LogoutCB(int val __UNUSED__, void *data __UNUSED__)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_X11_SM_SMLIB_H
|
#ifdef HAVE_X11_SM_SMLIB_H
|
||||||
if (sm_conn)
|
if (sm_conn)
|
||||||
|
@ -932,11 +931,8 @@ LogoutCB(int val, void *data)
|
||||||
else
|
else
|
||||||
#endif /* HAVE_X11_SM_SMLIB_H */
|
#endif /* HAVE_X11_SM_SMLIB_H */
|
||||||
{
|
{
|
||||||
doSMExit(NULL);
|
SessionExit(NULL);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
val = 0;
|
|
||||||
data = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -988,6 +984,10 @@ doSMExit(const void *params)
|
||||||
SaveSession(1);
|
SaveSession(1);
|
||||||
if ((disp) && ((!params) || ((params) && strcmp((char *)params, "logout"))))
|
if ((disp) && ((!params) || ((params) && strcmp((char *)params, "logout"))))
|
||||||
SetEInfoOnAll();
|
SetEInfoOnAll();
|
||||||
|
|
||||||
|
if (disp)
|
||||||
|
XSelectInput(disp, VRoot.win, 0);
|
||||||
|
|
||||||
if ((!params) || (!strcmp((char *)s, "exit")))
|
if ((!params) || (!strcmp((char *)s, "exit")))
|
||||||
{
|
{
|
||||||
callback_die(sm_conn, NULL);
|
callback_die(sm_conn, NULL);
|
||||||
|
@ -1231,6 +1231,13 @@ doSMExit(const void *params)
|
||||||
int
|
int
|
||||||
SessionExit(const void *param)
|
SessionExit(const void *param)
|
||||||
{
|
{
|
||||||
|
if (Mode.wm.exiting++)
|
||||||
|
{
|
||||||
|
/* This may be possible during nested signal handling */
|
||||||
|
Eprintf("SessionExit already in progress ... now exiting\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
doSMExit(param);
|
doSMExit(param);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ SetupX(void)
|
||||||
XSetIOErrorHandler((XIOErrorHandler) HandleXIOError);
|
XSetIOErrorHandler((XIOErrorHandler) HandleXIOError);
|
||||||
|
|
||||||
/* select all the root window events to start managing */
|
/* select all the root window events to start managing */
|
||||||
Mode.xselect = 1;
|
Mode.wm.xselect = 1;
|
||||||
XSelectInput(disp, VRoot.win,
|
XSelectInput(disp, VRoot.win,
|
||||||
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
ButtonPressMask | ButtonReleaseMask | EnterWindowMask |
|
||||||
LeaveWindowMask | ButtonMotionMask | PropertyChangeMask |
|
LeaveWindowMask | ButtonMotionMask | PropertyChangeMask |
|
||||||
|
@ -286,7 +286,7 @@ SetupX(void)
|
||||||
PointerMotionMask | ResizeRedirectMask |
|
PointerMotionMask | ResizeRedirectMask |
|
||||||
SubstructureNotifyMask);
|
SubstructureNotifyMask);
|
||||||
XSync(disp, False);
|
XSync(disp, False);
|
||||||
Mode.xselect = 0;
|
Mode.wm.xselect = 0;
|
||||||
|
|
||||||
/* warn, if necessary about X version problems */
|
/* warn, if necessary about X version problems */
|
||||||
if (ProtocolVersion(disp) != 11)
|
if (ProtocolVersion(disp) != 11)
|
||||||
|
|
|
@ -871,7 +871,7 @@ Real_SaveSnapInfo(int dumval __UNUSED__, void *dumdat __UNUSED__)
|
||||||
char buf[4096], s[4096];
|
char buf[4096], s[4096];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
if (!Mode.save_ok)
|
if (!Mode.wm.save_ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Etmp(s);
|
Etmp(s);
|
||||||
|
|
Loading…
Reference in New Issue