summaryrefslogtreecommitdiff
path: root/nopsyncd/nopsyncd.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-03-09 18:58:14 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-03-09 18:58:14 (GMT)
commitc0479f190fd22d7e6a2fa81f9eda2bd79a4b87b6 (patch)
tree435d2de991643b72a10d27011e45193e348d840e /nopsyncd/nopsyncd.c
parent9f014d5b9735a63da0e7d783f4c67a984140f7ab (diff)
exit whole process is one of the threads terminates
Diffstat (limited to 'nopsyncd/nopsyncd.c')
-rw-r--r--nopsyncd/nopsyncd.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/nopsyncd/nopsyncd.c b/nopsyncd/nopsyncd.c
index d478b18..f216d1e 100644
--- a/nopsyncd/nopsyncd.c
+++ b/nopsyncd/nopsyncd.c
@@ -121,6 +121,10 @@ void* main_loop(void* file)
printf("%s returned with %d\n", (char*)file, ret);
lua_close(L);
+
+ /* this should bring down the other thread as well
+ at least this is true for the tcp-server thread */
+ pipe_close();
pthread_exit(NULL);
}
@@ -142,6 +146,7 @@ int main(int argc, char* argv[])
fprintf(stderr, "Error creating qlistener thread (code: %d)\n", ret);
return 1;
}
+ pthread_detach(qlistener); /* can't kill this thread so don't join to it */
ret = pthread_create(&tcpserver, NULL, main_loop, "tcpserver.lua");
if(ret) {
@@ -149,16 +154,10 @@ int main(int argc, char* argv[])
return 1;
}
- pthread_join(qlistener, NULL);
+/* this thread can't be cancelled so don't wait for it */
+/* pthread_join(qlistener, NULL); */
pthread_join(tcpserver, NULL);
- ret = pipe_close();
- if(ret) {
- fprintf(stderr, "Error destroying pipe: %s\n", strerror(errno));
- return 1;
- }
-
-
printf("stopping nopsyncd.\n");
return 0;
}