Adding tty thread primitive which only reports alive status every 10 seconds.

This commit is contained in:
Luka Miljak 2014-03-14 17:28:29 +01:00
parent be121ac22f
commit 3926b7738d
4 changed files with 37 additions and 7 deletions

View file

@ -1,5 +1,6 @@
#include "moxerver.h"
#include <signal.h> /* handling quit signals */
#include <pthread.h>
#define NAME "moxerver"
@ -49,6 +50,8 @@ int main(int argc, char *argv[]) {
fd_set read_fds;
int fdmax;
struct timeval tv;
pthread_t tty_thread;
/* catch and handle some quit signals, SIGKILL can't be caught */
@ -107,7 +110,7 @@ int main(int argc, char *argv[]) {
//TODO this is a good place to create and start the TTY thread, use "tty_path" when opening device
ret = pthread_create(&tty_thread, NULL, tty_thread_func, "starting tty thread...");
/* loop with timeouts waiting for client connection and data*/
while (1) {
@ -177,10 +180,12 @@ int main(int argc, char *argv[]) {
} /* END while() loop */
pthread_join(tty_thread, NULL);
/* unexpected break from while() loop */
fprintf(stderr, "[%s] unexpected condition\n", NAME);
/* cleanup and exit with -1 */
cleanup(-1);
return -1;
}
}