1 char *ckusigv = "Signal support, 9.0.100, 16 Oct 2009";
3 /* C K U S I G -- Kermit signal handling for Unix and OS/2 systems */
6 Author: Jeffrey Altman (jaltman@secure-endpoints.com),
7 Secure Endpoints Inc., New York City.
9 Copyright (C) 1985, 2009,
10 Trustees of Columbia University in the City of New York.
11 All rights reserved. See the C-Kermit COPYING.TXT file or the
12 copyright text in the ckcmai.c module for disclaimer and permissions.
15 #include "ckcasc.h" /* ASCII character symbols */
16 #include "ckcdeb.h" /* Debug & other symbols */
17 #include "ckcker.h" /* Kermit symbols */
18 #include "ckcnet.h" /* Network symbols */
33 extern ckjmpbuf cmjbuf;
37 #define signal msignal
43 SIGTYP (*msignal(int type, SIGTYP (*func)(int)))(int);
47 /* We know these are set here. MUST unset them before the definitions. */
48 #define signal vsignal
50 SIGTYP (*vsignal(int type, SIGTYP (*func)(int)))(int);
51 int valarm(int interval);
55 #define signal asignal
57 #define SIGALRM (_NUMSIG+1)
59 SIGTYP (*asignal(int type, SIGTYP (*func)(int)))(int);
60 unsigned aalarm(unsigned);
69 mov eax, dword ptr [esp+0x10]
79 exception_filter( void )
81 GetExceptionInformation ;
82 return( EXCEPTION_EXECUTE_HANDLER ) ;
95 cc_execute( ckjptr(sj_buf), ck_sigfunc dofunc, ck_sigfunc failfunc )
97 cc_execute( sj_buf, dofunc, failfunc)
101 #endif /* CK_ANSIC */
107 sj_buf->retcode = 0 ;
108 sj_buf->Id = GetCurrentThreadId() ;
109 memset( &sj_buf->context, 0, sizeof(CONTEXT) );
110 sj_buf->context.ContextFlags = CONTEXT_FULL ;
112 GetThreadContext(GetCurrentThread(), &(sj_buf->context) ) ;
115 mov ecx,dword ptr [sj_buf]
116 mov dword ptr [ecx+0xc4],esp
118 sj_buf->context.EFlags = 530 ;
119 sj_buf->context.Eip = ckgetIP()+0x0C ;
123 mov eax, dword ptr [sj_buf]
139 cksetjmp(ckjdref(sj_buf))
145 mov esp, ESPToRestore
151 rc = sj_buf->retcode ;
160 __except(exception_filter())
162 debug(F100,"cc_execute __except","",0);
168 longjmp(ckjdref(sj_buf),SIGINT);
176 #endif /* NOCCTRAP */
179 #ifdef CK_ANSIC /* ANSIC C declaration... */
180 alrm_execute(ckjptr(sj_buf),
187 #else /* Not ANSIC C ... */
200 #endif /* CK_ANSIC */
206 _PROTOTYP(SIGTYP (*savhandler), (int));
208 savalrm = alarm(timo);
209 savhandler = signal(SIGALRM, handler);
212 sj_buf->retcode = 0 ;
213 sj_buf->Id = GetCurrentThreadId();
214 memset(&sj_buf->context, 0, sizeof(CONTEXT));
215 sj_buf->context.ContextFlags = CONTEXT_FULL;
217 GetThreadContext(GetCurrentThread(), &(sj_buf->context));
221 mov eax, dword ptr [sj_buf]
238 cksetjmp(ckjdref(sj_buf))
248 __except( exception_filter() )
250 debug(F100,"alrm_execute __except","",0);
251 debug(F111,"exception_filter",
255 longjmp(ckjdref(sj_buf),SIGINT);
263 signal( SIGALRM, savhandler ) ;
268 #ifdef CK_ANSIC /* ANSIC C declaration... */
269 cc_alrm_execute(ckjptr(sj_buf),
276 #else /* Not ANSIC C ... */
278 cc_alrm_execute(sj_buf,
289 #endif /* CK_ANSIC */
291 /* cc_alrm_execute */ {
295 _PROTOTYP(SIGTYP (*savhandler), (int));
296 savalrm = alarm(timo);
297 savhandler = signal( SIGALRM, handler );
300 sj_buf->retcode = 0 ;
301 sj_buf->Id = GetCurrentThreadId() ;
302 memset( &sj_buf->context, 0, sizeof(CONTEXT) );
303 sj_buf->context.ContextFlags = CONTEXT_FULL ;
305 GetThreadContext( GetCurrentThread(), &(sj_buf->context) ) ;
309 mov eax, dword ptr [sj_buf]
326 cksetjmp(ckjdref(sj_buf))
336 __except( exception_filter() )
338 debug(F100,"cc_alrm_execute __except","",0);
344 longjmp(ckjdref(sj_buf),SIGINT) ;
352 signal(SIGALRM,savhandler);