]> git.sesse.net Git - cubemap/blobdiff - main.cpp
Explicitly SIGHUP threads to kill them out of syscalls when we want to join them...
[cubemap] / main.cpp
index 2af1996fe670d7152c81552e00018f17052f3aac..0564e27e8a2a865e1ea9e0f62cf7bc622c27c5d4 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -94,7 +94,7 @@ void *acceptor_thread_run(void *arg)
                pfd.events = POLLIN;
 
                int nfds = poll(&pfd, 1, 50);
-               if (nfds == 0 || (nfds == -1 && errno == EAGAIN)) {
+               if (nfds == 0 || (nfds == -1 && errno == EINTR)) {
                        continue;
                }
                if (nfds == -1) {
@@ -187,7 +187,7 @@ sleep:
                int left_to_sleep = parms->stats_interval;
                do {
                        left_to_sleep = sleep(left_to_sleep);
-               } while (left_to_sleep > 0);
+               } while (left_to_sleep > 0 && !hupped);
        }
        return NULL;
 }
@@ -433,11 +433,13 @@ int main(int argc, char **argv)
        gettimeofday(&serialize_start, NULL);
 
        if (!stats_file.empty()) {
+               pthread_kill(stats_thread, SIGHUP);
                if (pthread_join(stats_thread, NULL) == -1) {
                        perror("pthread_join");
                        exit(1);
                }
        }
+       pthread_kill(acceptor_thread, SIGHUP);
        if (pthread_join(acceptor_thread, NULL) == -1) {
                perror("pthread_join");
                exit(1);