blob: a092bd38b57906c461a8769ddc6ff72789df382b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <nwthread.h>
#include <nwerrno.h>
/*******************************/
/* Interupt handler */
/*******************************/
int NLM_mainThreadGroupID;
int NLM_threadCnt = 0;
int NLM_exiting = FALSE;
#pragma off(unreferenced);
void NLM_SignalHandler(int sig)
#pragma on(unreferenced);
{
int handlerThreadGroupID;
switch(sig)
{
case SIGTERM:
NLM_exiting = TRUE;
handlerThreadGroupID = GetThreadGroupID();
SetThreadGroupID(NLM_mainThreadGroupID);
/* NLM SDK functions may be called here */
while (NLM_threadCnt != 0)
ThreadSwitchWithDelay();
SetThreadGroupID(handlerThreadGroupID);
break;
case SIGINT:
signal(SIGINT, NLM_SignalHandler);
break;
}
return;
}
void NLMsignals(void)
{
++NLM_threadCnt;
NLM_mainThreadGroupID = GetThreadGroupID();
signal(SIGTERM, NLM_SignalHandler);
signal(SIGINT, NLM_SignalHandler);
}
void NLMexit(void)
{
--NLM_threadCnt;
}
|