17 if (pipe2(pipefd, O_CLOEXEC) == -1) {
21 stop_fd_read = pipefd[0];
22 stop_fd_write = pipefd[1];
23 pthread_create(&worker_thread, NULL, &Thread::do_work_thunk, this);
32 err = write(stop_fd_write, &ch, 1);
33 } while (err == -1 && errno == EINTR);
41 err = close(stop_fd_write);
42 } while (err == -1 && errno == EINTR);
46 // Can continue (we have close-on-exec).
49 pthread_kill(worker_thread, SIGHUP);
50 if (pthread_join(worker_thread, NULL) == -1) {
51 log_perror("pthread_join");
56 err = close(stop_fd_read);
57 } while (err == -1 && errno == EINTR);
61 // Can continue (we have close-on-exec).
65 void *Thread::do_work_thunk(void *arg)
67 Thread *thread = reinterpret_cast<Thread *>(arg);