1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 03:32:24 +00:00

dtlogin: use POSIX.1 non-local jumps.

This commit is contained in:
Liang Chang 2022-02-07 06:42:17 +08:00
parent 9077b5fd85
commit 5fb7f4da67
9 changed files with 41 additions and 43 deletions

View file

@ -58,7 +58,6 @@
***************************************************************************/ ***************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <setjmp.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/signal.h> #include <sys/signal.h>

View file

@ -39,7 +39,6 @@
# include <signal.h> # include <signal.h>
# include <X11/Xatom.h> # include <X11/Xatom.h>
# include <X11/Xmu/Error.h> # include <X11/Xmu/Error.h>
# include <setjmp.h>
#if defined(__FreeBSD__) && OSMAJORVERSION > 8 #if defined(__FreeBSD__) && OSMAJORVERSION > 8
# include <utmpx.h> # include <utmpx.h>
#else #else

View file

@ -110,12 +110,12 @@ killWindows( Display *dpy, Window window )
} }
} }
static jmp_buf resetJmp; static sigjmp_buf resetJmp;
static SIGVAL static SIGVAL
abortReset( int arg ) abortReset( int arg )
{ {
longjmp (resetJmp, 1); siglongjmp (resetJmp, 1);
} }
/* /*
@ -128,7 +128,7 @@ pseudoReset( Display *dpy )
Window root; Window root;
int screen; int screen;
if (setjmp (resetJmp)) { if (sigsetjmp (resetJmp, 1)) {
LogError( LogError(
ReadCatalog(MC_LOG_SET,MC_LOG_PSEUDO,MC_DEF_LOG_PSEUDO)); ReadCatalog(MC_LOG_SET,MC_LOG_PSEUDO,MC_DEF_LOG_PSEUDO));
} else { } else {

View file

@ -223,14 +223,14 @@ StartServer( struct display *d )
* the sleep finishes, 0 else * the sleep finishes, 0 else
*/ */
static jmp_buf pauseAbort; static sigjmp_buf pauseAbort;
static int serverPauseRet; static int serverPauseRet;
static SIGVAL static SIGVAL
serverPauseAbort( int arg ) serverPauseAbort( int arg )
{ {
Debug ("Display Manager pause timed out\n"); Debug ("Display Manager pause timed out\n");
longjmp (pauseAbort, 1); siglongjmp (pauseAbort, 1);
} }
static SIGVAL static SIGVAL
@ -238,7 +238,7 @@ serverPauseUsr1( int arg )
{ {
Debug ("Display Manager pause received SIGUSR1\n"); Debug ("Display Manager pause received SIGUSR1\n");
++receivedUsr1; ++receivedUsr1;
longjmp (pauseAbort, 1); siglongjmp (pauseAbort, 1);
} }
static int static int
@ -248,7 +248,7 @@ serverPause( unsigned t, int serverPid )
serverPauseRet = 0; serverPauseRet = 0;
Debug ("Display Manager pausing until SIGUSR1 from server or timeout\n"); Debug ("Display Manager pausing until SIGUSR1 from server or timeout\n");
if (!setjmp (pauseAbort)) { if (!sigsetjmp (pauseAbort, 1)) {
signal (SIGALRM, serverPauseAbort); signal (SIGALRM, serverPauseAbort);
signal (SIGUSR1, serverPauseUsr1); signal (SIGUSR1, serverPauseUsr1);
#ifdef SYSV #ifdef SYSV
@ -308,17 +308,17 @@ serverPause( unsigned t, int serverPid )
/* /*
* this code is complicated by some TCP failings. On * this code is complicated by some TCP failings. On
* many systems, the connect will occasionally hang forever, * many systems, the connect will occasionally hang forever,
* this trouble is avoided by setting up a timeout to longjmp * this trouble is avoided by setting up a timeout to siglongjmp
* out of the connect (possibly leaving piles of garbage around * out of the connect (possibly leaving piles of garbage around
* inside Xlib) and give up, terminating the server. * inside Xlib) and give up, terminating the server.
*/ */
static jmp_buf openAbort; static sigjmp_buf openAbort;
static SIGVAL static SIGVAL
abortOpen( int arg ) abortOpen( int arg )
{ {
longjmp (openAbort, 1); siglongjmp (openAbort, 1);
} }
static void static void
@ -378,7 +378,7 @@ WaitForServer( struct display *d )
for (i = 0; i < (d->openRepeat > 0 ? d->openRepeat : 1); i++) { for (i = 0; i < (d->openRepeat > 0 ? d->openRepeat : 1); i++) {
(void) signal (SIGALRM, abortOpen); (void) signal (SIGALRM, abortOpen);
(void) alarm ((unsigned) d->openTimeout); (void) alarm ((unsigned) d->openTimeout);
if (!setjmp (openAbort)) { if (!sigsetjmp (openAbort, 1)) {
Debug ("Before XOpenDisplay(%s)\n", d->name); Debug ("Before XOpenDisplay(%s)\n", d->name);
errno = 0; errno = 0;
dpy = XOpenDisplay (d->name); dpy = XOpenDisplay (d->name);
@ -443,14 +443,14 @@ ResetServer( struct display *d )
* *
****************************************************************************/ ****************************************************************************/
static jmp_buf pingTime; static sigjmp_buf pingTime;
static int serverDead = FALSE; static int serverDead = FALSE;
static SIGVAL static SIGVAL
PingLost( int arg ) PingLost( int arg )
{ {
serverDead = TRUE; serverDead = TRUE;
longjmp (pingTime, 1); siglongjmp (pingTime, 1);
} }
@ -458,7 +458,7 @@ static SIGVAL
PingBlocked( int arg ) PingBlocked( int arg )
{ {
serverDead = FALSE; serverDead = FALSE;
longjmp (pingTime, 1); siglongjmp (pingTime, 1);
} }
@ -475,7 +475,7 @@ PingServer( struct display *d, Display *alternateDpy )
oldAlarm = alarm (0); oldAlarm = alarm (0);
oldSig = signal (SIGALRM, PingBlocked); oldSig = signal (SIGALRM, PingBlocked);
alarm (d->pingTimeout * 60); alarm (d->pingTimeout * 60);
if (!setjmp (pingTime)) if (!sigsetjmp (pingTime, 1))
{ {
Debug ("Ping server\n"); Debug ("Ping server\n");
XNoOp (alternateDpy); XNoOp (alternateDpy);

View file

@ -239,7 +239,7 @@ static struct greet_info greet;
static struct verify_info verify; static struct verify_info verify;
static char *defaultLanguage = NULL; static char *defaultLanguage = NULL;
static jmp_buf abortSession; static sigjmp_buf abortSession;
#ifdef BLS #ifdef BLS
static char *sensitivityLevel; static char *sensitivityLevel;
@ -257,15 +257,15 @@ XrmDatabase XDB;
static SIGVAL static SIGVAL
catchTerm( int arg ) catchTerm( int arg )
{ {
longjmp (abortSession, 1); siglongjmp (abortSession, 1);
} }
static jmp_buf pingTime; static sigjmp_buf pingTime;
static SIGVAL static SIGVAL
catchAlrm( int arg ) catchAlrm( int arg )
{ {
longjmp (pingTime, 1); siglongjmp (pingTime, 1);
} }
#if defined(__STDC__) #if defined(__STDC__)
@ -522,7 +522,7 @@ ManageSession( struct display *d )
#endif #endif
clientPid = 0; clientPid = 0;
if (!setjmp (abortSession)) { if (!sigsetjmp (abortSession, 1)) {
signal (SIGTERM, catchTerm); signal (SIGTERM, catchTerm);
/* /*
* Start the clients, changing uid/groups * Start the clients, changing uid/groups
@ -543,7 +543,7 @@ ManageSession( struct display *d )
for (;;) { for (;;) {
if (d->pingInterval) if (d->pingInterval)
{ {
if (!setjmp (pingTime)) if (!sigsetjmp (pingTime, 1))
{ {
signal (SIGALRM, catchAlrm); signal (SIGALRM, catchAlrm);
alarm (d->pingInterval * 60); alarm (d->pingInterval * 60);
@ -1064,12 +1064,12 @@ DeleteXloginResources( struct display *d, Display *dpy )
#if 0 /* dead code: transferred to Dtgreet */ #if 0 /* dead code: transferred to Dtgreet */
static jmp_buf syncJump; static sigjmp_buf syncJump;
static SIGVAL static SIGVAL
syncTimeout () syncTimeout ()
{ {
longjmp (syncJump, 1); siglongjmp (syncJump, 1);
} }
@ -1079,7 +1079,7 @@ Display *dpy;
{ {
Debug ("SecureDisplay():\n"); Debug ("SecureDisplay():\n");
signal (SIGALRM, syncTimeout); signal (SIGALRM, syncTimeout);
if (setjmp (syncJump)) { if (sigsetjmp (syncJump, 1)) {
LogError(ReadCatalog(MC_LOG_SET,MC_LOG_NO_SECDPY,MC_DEF_LOG_NO_SECDPY), LogError(ReadCatalog(MC_LOG_SET,MC_LOG_NO_SECDPY,MC_DEF_LOG_NO_SECDPY),
d->name); d->name);
SessionExit (d, RESERVER_DISPLAY); SessionExit (d, RESERVER_DISPLAY);
@ -1689,12 +1689,12 @@ StartClient( struct verify_info *verify, struct display *d, int *pidp )
} }
} }
static jmp_buf tenaciousClient; static sigjmp_buf tenaciousClient;
static SIGVAL static SIGVAL
waitAbort( int arg ) waitAbort( int arg )
{ {
longjmp (tenaciousClient, 1); siglongjmp (tenaciousClient, 1);
} }
#if defined(SYSV) || defined(SVR4) #if defined(SYSV) || defined(SVR4)
@ -1723,7 +1723,7 @@ AbortClient( int pid )
return 0; return 0;
} }
} }
if (!setjmp (tenaciousClient)) { if (!sigsetjmp (tenaciousClient, 1)) {
(void) signal (SIGALRM, waitAbort); (void) signal (SIGALRM, waitAbort);
(void) alarm ((unsigned) 10); (void) alarm ((unsigned) 10);
retId = wait ((waitType *) 0); retId = wait ((waitType *) 0);
@ -1948,7 +1948,7 @@ RunGreeter( struct display *d, struct greet_info *greet,
#endif #endif
greeterPid = 0; greeterPid = 0;
if (!setjmp (abortSession)) { if (!sigsetjmp (abortSession, 1)) {
signal(SIGTERM, catchTerm); signal(SIGTERM, catchTerm);
/* /*

View file

@ -428,13 +428,13 @@ SetHourGlassCursor( Display *dpy, Window w )
#define DELIM " \t" /* delimiters in language list */ #define DELIM " \t" /* delimiters in language list */
static jmp_buf langJump; static sigjmp_buf langJump;
static SIGVAL static SIGVAL
MakeLangAbort( int arg ) MakeLangAbort( int arg )
{ {
longjmp (langJump, 1); siglongjmp (langJump, 1);
} }
void void
@ -459,7 +459,7 @@ MakeLangList( void )
signal (SIGALRM, MakeLangAbort); signal (SIGALRM, MakeLangAbort);
alarm ((unsigned) langListTimeout); alarm ((unsigned) langListTimeout);
if (!setjmp (langJump)) { if (!sigsetjmp (langJump, 1)) {
ScanNLSDir(DEF_NLS_DIR); ScanNLSDir(DEF_NLS_DIR);
} }
else { else {

View file

@ -947,7 +947,7 @@ OptionsUnmapCB( Widget wd, XtPointer client_data, XtPointer call_data )
* *
***************************************************************************/ ***************************************************************************/
static jmp_buf pingTime; static sigjmp_buf pingTime;
static int serverDead = FALSE; static int serverDead = FALSE;
static int pingInterval = 0; /* ping interval (sec.) */ static int pingInterval = 0; /* ping interval (sec.) */
static int pingTimeout; /* ping timeout (sec.) */ static int pingTimeout; /* ping timeout (sec.) */
@ -956,7 +956,7 @@ static void
PingLost( void ) PingLost( void )
{ {
serverDead = TRUE; serverDead = TRUE;
longjmp (pingTime, 1); siglongjmp (pingTime, 1);
} }
@ -965,7 +965,7 @@ PingBlocked( int arg )
{ {
serverDead = TRUE; serverDead = TRUE;
longjmp (pingTime, 1); siglongjmp (pingTime, 1);
} }
@ -980,7 +980,7 @@ PingServer( void )
oldAlarm = alarm (0); oldAlarm = alarm (0);
oldSig = signal (SIGALRM, PingBlocked); oldSig = signal (SIGALRM, PingBlocked);
alarm (pingTimeout * 60); alarm (pingTimeout * 60);
if (!setjmp (pingTime)) if (!sigsetjmp (pingTime, 1))
{ {
XSync (dpyinfo.dpy, 0); XSync (dpyinfo.dpy, 0);
} }

View file

@ -671,13 +671,13 @@ main( int argc, char **argv )
#define MINTIMEOUT 20 #define MINTIMEOUT 20
static jmp_buf syncJump; static sigjmp_buf syncJump;
static SIGVAL static SIGVAL
syncTimeout( int arg ) syncTimeout( int arg )
{ {
longjmp (syncJump, 1); siglongjmp (syncJump, 1);
} }
@ -707,7 +707,7 @@ InitToolKit( int argc, char **argv )
*/ */
signal (SIGALRM, syncTimeout); signal (SIGALRM, syncTimeout);
if (setjmp (syncJump)) { if (sigsetjmp (syncJump, 1)) {
LogError( LogError(
ReadCatalog(MC_LOG_SET,MC_LOG_NO_DPYINIT,MC_DEF_LOG_NO_DPYINIT), ReadCatalog(MC_LOG_SET,MC_LOG_NO_DPYINIT,MC_DEF_LOG_NO_DPYINIT),
dpyinfo.name); dpyinfo.name);

View file

@ -824,14 +824,14 @@ ReadCatalogXms(int setn, int msgn, char *dflt)
* grab/release the server and keyboard * grab/release the server and keyboard
***************************************************************************/ ***************************************************************************/
static jmp_buf syncJump; static sigjmp_buf syncJump;
static int grabServer; /* Boolean on grabbing server */ static int grabServer; /* Boolean on grabbing server */
static int grabTimeout; /* timeout to grab server */ static int grabTimeout; /* timeout to grab server */
static SIGVAL static SIGVAL
syncTimeout( int arg ) syncTimeout( int arg )
{ {
longjmp (syncJump, 1); siglongjmp (syncJump, 1);
} }
int int
@ -853,7 +853,7 @@ SecureDisplay( void )
* grab server then the keyboard... * grab server then the keyboard...
*/ */
signal (SIGALRM, syncTimeout); signal (SIGALRM, syncTimeout);
if (setjmp (syncJump)) { if (sigsetjmp (syncJump, 1)) {
LogError(ReadCatalog(MC_LOG_SET,MC_LOG_NO_SECDPY,MC_DEF_LOG_NO_SECDPY), LogError(ReadCatalog(MC_LOG_SET,MC_LOG_NO_SECDPY,MC_DEF_LOG_NO_SECDPY),
dpyinfo.name); dpyinfo.name);
return(1); return(1);