mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 21:38:00 +01:00
Change to the linux kernel coding style
for arq in `git ls-files *.c`; do
echo $arq;
indent -linux -l115 $arq;
done
The different line break at 115 columns is because
I use a widescreen monitor :-)
This commit is contained in:
169
src/monitor.c
169
src/monitor.c
@@ -46,115 +46,98 @@ extern WPreferences wPreferences;
|
||||
|
||||
extern int wScreenCount;
|
||||
|
||||
|
||||
|
||||
|
||||
int showCrashDialog(int sig)
|
||||
{
|
||||
int crashAction;
|
||||
|
||||
dpy = XOpenDisplay(NULL);
|
||||
if (dpy) {
|
||||
int crashAction;
|
||||
|
||||
dpy = XOpenDisplay(NULL);
|
||||
if (dpy) {
|
||||
/* XXX TODO make sure that window states are saved and restored via netwm */
|
||||
|
||||
XGrabServer(dpy);
|
||||
crashAction = wShowCrashingDialogPanel(sig);
|
||||
XCloseDisplay(dpy);
|
||||
dpy = NULL;
|
||||
} else {
|
||||
wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
|
||||
crashAction = WMAbort;
|
||||
}
|
||||
|
||||
if (crashAction == WMStartAlternate)
|
||||
{
|
||||
int i;
|
||||
XGrabServer(dpy);
|
||||
crashAction = wShowCrashingDialogPanel(sig);
|
||||
XCloseDisplay(dpy);
|
||||
dpy = NULL;
|
||||
} else {
|
||||
wsyserror(_("cannot open connection for crashing dialog panel. Aborting."));
|
||||
crashAction = WMAbort;
|
||||
}
|
||||
|
||||
wmessage(_("trying to start alternate window manager..."));
|
||||
if (crashAction == WMStartAlternate) {
|
||||
int i;
|
||||
|
||||
for (i=0; i<WMGetArrayItemCount(wPreferences.fallbackWMs); i++) {
|
||||
Restart(WMGetFromArray(wPreferences.fallbackWMs, i), False);
|
||||
}
|
||||
wmessage(_("trying to start alternate window manager..."));
|
||||
|
||||
wfatal(_("failed to start alternate window manager. Aborting."));
|
||||
for (i = 0; i < WMGetArrayItemCount(wPreferences.fallbackWMs); i++) {
|
||||
Restart(WMGetFromArray(wPreferences.fallbackWMs, i), False);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if (crashAction == WMAbort)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
wfatal(_("failed to start alternate window manager. Aborting."));
|
||||
|
||||
return 0;
|
||||
} else if (crashAction == WMAbort)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int MonitorLoop(int argc, char **argv)
|
||||
{
|
||||
pid_t pid, exited;
|
||||
char **child_argv= wmalloc(sizeof(char*)*(argc+2));
|
||||
int i, status;
|
||||
time_t last_start;
|
||||
Bool error = False;
|
||||
pid_t pid, exited;
|
||||
char **child_argv = wmalloc(sizeof(char *) * (argc + 2));
|
||||
int i, status;
|
||||
time_t last_start;
|
||||
Bool error = False;
|
||||
|
||||
for (i= 0; i < argc; i++)
|
||||
child_argv[i]= argv[i];
|
||||
child_argv[i++]= "--for-real";
|
||||
child_argv[i]= NULL;
|
||||
for (i = 0; i < argc; i++)
|
||||
child_argv[i] = argv[i];
|
||||
child_argv[i++] = "--for-real";
|
||||
child_argv[i] = NULL;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
last_start= time(NULL);
|
||||
for (;;) {
|
||||
last_start = time(NULL);
|
||||
|
||||
/* Start Window Maker */
|
||||
pid = fork();
|
||||
if (pid == 0)
|
||||
{
|
||||
execvp(child_argv[0], child_argv);
|
||||
wsyserror(_("Error respawning Window Maker"));
|
||||
exit(1);
|
||||
}
|
||||
else if (pid < 0)
|
||||
{
|
||||
wsyserror(_("Error respawning Window Maker"));
|
||||
exit(1);
|
||||
}
|
||||
/* Start Window Maker */
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
execvp(child_argv[0], child_argv);
|
||||
wsyserror(_("Error respawning Window Maker"));
|
||||
exit(1);
|
||||
} else if (pid < 0) {
|
||||
wsyserror(_("Error respawning Window Maker"));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
do {
|
||||
if ((exited=waitpid(-1, &status, 0)) < 0)
|
||||
{
|
||||
wsyserror(_("Error during monitoring of Window Maker process."));
|
||||
error = True;
|
||||
break;
|
||||
}
|
||||
} while (exited != pid);
|
||||
do {
|
||||
if ((exited = waitpid(-1, &status, 0)) < 0) {
|
||||
wsyserror(_("Error during monitoring of Window Maker process."));
|
||||
error = True;
|
||||
break;
|
||||
}
|
||||
} while (exited != pid);
|
||||
|
||||
if (error)
|
||||
break;
|
||||
if (error)
|
||||
break;
|
||||
|
||||
child_argv[argc]= "--for-real-";
|
||||
|
||||
/* Check if the wmaker process exited due to a crash */
|
||||
if (WIFSIGNALED(status) &&
|
||||
(WTERMSIG(status) == SIGSEGV ||
|
||||
WTERMSIG(status) == SIGBUS ||
|
||||
WTERMSIG(status) == SIGILL ||
|
||||
WTERMSIG(status) == SIGABRT ||
|
||||
WTERMSIG(status) == SIGFPE))
|
||||
{
|
||||
/* If so, we check when was the last restart.
|
||||
* If it was less than 3s ago, it's a bad sign, so we show
|
||||
* the crash panel and ask the user what to do */
|
||||
if (time(NULL) - last_start < 3)
|
||||
{
|
||||
if (showCrashDialog(WTERMSIG(status)) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
wwarning(_("Window Maker exited due to a crash (signal %i) and will be restarted."),
|
||||
WTERMSIG(status));
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
child_argv[argc] = "--for-real-";
|
||||
|
||||
/* Check if the wmaker process exited due to a crash */
|
||||
if (WIFSIGNALED(status) &&
|
||||
(WTERMSIG(status) == SIGSEGV ||
|
||||
WTERMSIG(status) == SIGBUS ||
|
||||
WTERMSIG(status) == SIGILL || WTERMSIG(status) == SIGABRT || WTERMSIG(status) == SIGFPE)) {
|
||||
/* If so, we check when was the last restart.
|
||||
* If it was less than 3s ago, it's a bad sign, so we show
|
||||
* the crash panel and ask the user what to do */
|
||||
if (time(NULL) - last_start < 3) {
|
||||
if (showCrashDialog(WTERMSIG(status)) == 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
wwarning(_("Window Maker exited due to a crash (signal %i) and will be restarted."),
|
||||
WTERMSIG(status));
|
||||
} else
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user