From 4a9df9b604cec6ee4b4a6f01ef940443583f7573 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Thu, 26 Dec 2019 18:32:26 +0100 Subject: Still working on the daemonization (and rewrite). I am not sure that what I am doing is going to provide what was requested in https://github.com/nsensfel/relabsd/issues/3 but it will at the very least turn relabsd into a proper daemon, and the additions will help create some kind of relabsd device manager if someone needs such a thing. --- src/server/communication_thread.c | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/server/communication_thread.c (limited to 'src/server/communication_thread.c') diff --git a/src/server/communication_thread.c b/src/server/communication_thread.c new file mode 100644 index 0000000..2ed1aae --- /dev/null +++ b/src/server/communication_thread.c @@ -0,0 +1,55 @@ +/**** POSIX *******************************************************************/ +#include +#include + +/**** RELABSD *****************************************************************/ +#include + +/******************************************************************************/ +/**** LOCAL FUNCTIONS *********************************************************/ +/******************************************************************************/ +void main_loop (struct relabsd_server server [const static 1]) +{ + +} + +void * posix_main_loop (void * params) +{ + main_loop((struct relabsd_server *) params); + + return NULL; +} + +/******************************************************************************/ +/**** EXPORTED FUNCTIONS ******************************************************/ +/******************************************************************************/ + +int relabsd_server_create_communication_thread +( + struct relabsd_server server [const static 1] +) +{ + int err; + + err = + pthread_create + ( + &(server->communication_thread), + (const pthread_attr_t *) NULL, + posix_main_loop, + (void *) server + ); + + if (err != 0) + { + RELABSD_FATAL + ( + "Unable to create the communication thread: %s", + strerror(err) + ); + + return -1; + } + + return 0; +} -- cgit v1.2.3-70-g09d2