# HG changeset patch
# User Edouard Tisserant
# Date 1438617718 -7200
# Node ID 8bfe0ac00cdb4d473664fcbf1228a0f6a42eee15
# Parent  2b9fd5086704e4bc90f79d35c25ae0749886488c# Parent  72e9e10644321caf15ce9c755e58120f353e222d
merged

diff -r 2b9fd5086704 -r 8bfe0ac00cdb drivers/timers_unix/timers_unix.c
--- a/drivers/timers_unix/timers_unix.c	Fri Jun 19 20:16:07 2015 +0200
+++ b/drivers/timers_unix/timers_unix.c	Mon Aug 03 18:01:58 2015 +0200
@@ -1,12 +1,12 @@
 #include <stdlib.h>
 
 #include <sys/time.h>
-#include <pthread.h> 
+#include <pthread.h>
 #include <signal.h>
 #include <time.h>
 
-#include "applicfg.h"
-#include "timer.h"
+#include <applicfg.h>
+#include <timer.h>
 
 static pthread_mutex_t CanFestival_mutex = PTHREAD_MUTEX_INITIALIZER;
 
@@ -104,6 +104,20 @@
   	//  if(signal(SIGTERM, canReceiveLoop_signal) == SIG_ERR) {
 	//		perror("signal()");
 	//}
+
+    // Set the cancelation state for immediatly cancel the task
+    int ret;
+
+    ret = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+
+    if (ret != 0)
+        perror("Can't enable the cancelation of the receiving task");
+
+    ret = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+    if (ret != 0)
+        perror("Can't set the asynchronous cancel typ");
+
     unixtimer_ReceiveLoop_task_proc((CAN_PORT)port);
 
     return NULL;
@@ -119,8 +133,8 @@
 
 void WaitReceiveTaskEnd(TASK_HANDLE *Thread)
 {
-	if(pthread_kill(*Thread, SIGTERM)) {
-		perror("pthread_kill()");
+	if(pthread_cancel(*Thread)) {
+		perror("pthread_cancel()");
 	}
 	if(pthread_join(*Thread, NULL)) {
 		perror("pthread_join()");