- should_stop = true;
- pthread_kill(worker_thread, SIGHUP);
- if (pthread_join(worker_thread, NULL) == -1) {
- perror("pthread_join");
- exit(1);
- }
+ // Unset the close-on-exec flag for the socket.
+ // (This can't leak into a child, since there's only one thread left.)
+ fcntl(server_sock, F_SETFD, 0);
+
+ char buf[INET6_ADDRSTRLEN];
+ inet_ntop(addr.sin6_family, &addr.sin6_addr, buf, sizeof(buf));
+
+ AcceptorProto serialized;
+ serialized.set_server_sock(server_sock);
+ serialized.set_addr(buf);
+ serialized.set_port(ntohs(addr.sin6_port));
+ serialized.set_certificate_chain(certificate_chain);
+ serialized.set_private_key(private_key);
+ return serialized;