diff options
Diffstat (limited to 'signals.c')
-rw-r--r-- | signals.c | 41 |
1 files changed, 33 insertions, 8 deletions
@@ -23,12 +23,19 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. ******************************************************************************/ +/* $XFree86: xc/programs/xsm/signals.c,v 3.6 2001/12/14 20:02:27 dawes Exp $ */ + +#include <stdlib.h> #include <X11/Xos.h> #include <X11/Xfuncs.h> +#include <X11/Intrinsic.h> #include <X11/SM/SMlib.h> +#include "save.h" + +#include <errno.h> #ifdef USG #ifndef __TYPES__ #include <sys/types.h> /* forgot to protect it... */ @@ -56,10 +63,16 @@ in this Software without prior written authorization from The Open Group. #else #define _POSIX_SOURCE #include <signal.h> +#ifdef SCO325 +#include <sys/procset.h> +#include <sys/siginfo.h> +#endif #include <sys/wait.h> #undef _POSIX_SOURCE #endif #endif +#include "list.h" +#include "save.h" #if defined(X_NOT_POSIX) && defined(SIGNALRETURNSINT) #define SIGVAL int @@ -83,12 +96,11 @@ in this Software without prior written authorization from The Open Group. #define SIGNALS_RESET_WHEN_CAUGHT #endif -#ifndef NULL -#define NULL 0 -#endif +#include <stddef.h> int checkpoint_from_signal = 0; +extern XtSignalId sig_term_id, sig_usr1_id; extern Bool wantShutdown; @@ -110,10 +122,10 @@ SIGVAL (*Signal (sig, handler))() void -sig_child_handler () +sig_child_handler (XtPointer closure, XtSignalId id) { - int pid; + int pid, olderrno = errno; #if !defined(USE_POSIX_WAIT) && (defined(USE_SYSV_SIGNALS) && \ (defined(CRAY) || !defined(SIGTSTP))) @@ -147,11 +159,18 @@ sig_child_handler () #endif /* USE_POSIX_WAIT else */ } while (pid > 0); + errno = olderrno; } +void +sig_term_handler(int sig) +{ + XtNoticeSignal(sig_term_id); +} + void -sig_term_handler () +xt_sig_term_handler (XtPointer closure, XtSignalId *id) { wantShutdown = 1; @@ -159,9 +178,13 @@ sig_term_handler () DoSave (SmSaveLocal, SmInteractStyleNone, 1 /* fast */); } +void sig_usr1_handler(int sig) +{ + XtNoticeSignal(sig_usr1_id); +} void -sig_usr1_handler () +xt_sig_usr1_handler (XtPointer closure, XtSignalId *id) { wantShutdown = 0; @@ -172,7 +195,7 @@ sig_usr1_handler () void -register_signals () +register_signals (XtAppContext appContext) { /* @@ -194,6 +217,7 @@ register_signals () */ Signal (SIGTERM, sig_term_handler); + sig_term_id = XtAppAddSignal(appContext, xt_sig_term_handler, NULL); /* @@ -201,6 +225,7 @@ register_signals () */ Signal (SIGUSR1, sig_usr1_handler); + sig_usr1_id = XtAppAddSignal(appContext, xt_sig_usr1_handler, NULL); } |