summaryrefslogtreecommitdiffstats
path: root/threads.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-12-14 17:58:12 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-12-14 17:58:12 +0000
commite45bbf5c66b5cb08c91bdb99ba1acf5f215c3112 (patch)
tree60d91c5ece80f8025a44484d674dbdcc3825faaa /threads.c
parent8d186b303650c1d942543e28fdf8cf28a451f438 (diff)
downloadrsyslog-e45bbf5c66b5cb08c91bdb99ba1acf5f215c3112.tar.gz
rsyslog-e45bbf5c66b5cb08c91bdb99ba1acf5f215c3112.tar.xz
rsyslog-e45bbf5c66b5cb08c91bdb99ba1acf5f215c3112.zip
graceful termination now supported
Diffstat (limited to 'threads.c')
-rw-r--r--threads.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/threads.c b/threads.c
index 96911403..139cf835 100644
--- a/threads.c
+++ b/threads.c
@@ -118,7 +118,7 @@ dbgprintf("thrdTerminateAll out\n");
* executing threads. It is added at the end of the list.
* rgerhards, 2007-12-14
*/
-rsRetVal thrdCreate(void* (*thrdMain)(void*))
+rsRetVal thrdCreate(void* (*thrdMain)(void*), eTermSyncType_t eTermSyncType)
{
DEFiRet;
thrdInfo_t *pThis;
@@ -127,6 +127,8 @@ rsRetVal thrdCreate(void* (*thrdMain)(void*))
assert(thrdMain != NULL);
CHKiRet(thrdConstruct(&pThis));
+ pThis->eTermTool = eTermSyncType;
+ pThis->bIsActive = 1;
i = pthread_create(&pThis->thrdID, NULL, thrdMain, NULL);
CHKiRet(llAppend(&llThrds, NULL, pThis));
@@ -135,15 +137,31 @@ finalize_it:
}
+/* This is a dummy handler. We user SIGUSR2 to interrupt blocking system calls
+ * if we are in termination mode 1.
+ */
+static void sigusr2Dummy(int sig)
+{
+ dbgprintf("sigusr2Dummy called!\n");
+}
+
+
/* initialize the thread-support subsystem
* must be called once at the start of the program
*/
rsRetVal thrdInit(void)
{
DEFiRet;
+ struct sigaction sigAct;
iRet = llInit(&llThrds, thrdDestruct, NULL, NULL);
+ /* set up our termination subsystem */
+ memset(&sigAct, 0, sizeof (sigAct));
+ sigemptyset(&sigAct.sa_mask);
+ sigAct.sa_handler = sigusr2Dummy;
+ sigaction(SIGUSR2, &sigAct, NULL);
+
return iRet;
}