+/*
+ * Connect two sockets to each other to emulate the pipe() system call on Windows.
+ */
+int pipe_over_loopback(int fd[2])
+{
+ struct sockaddr_in addr = { .sin_family = AF_INET };
+ socklen_t len = sizeof(addr);
+ int res;
+
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+
+ sock_init();
+
+ fd[0] = socket(AF_INET, SOCK_STREAM, 0);
+ if (fd[0] < 0)
+ goto err;
+ fd[1] = socket(AF_INET, SOCK_STREAM, 0);
+ if (fd[1] < 0)
+ goto close_fd_0;
+ res = bind(fd[0], (struct sockaddr *)&addr, len);
+ if (res < 0)
+ goto close_fd_1;
+ res = getsockname(fd[0], (struct sockaddr *)&addr, &len);
+ if (res < 0)
+ goto close_fd_1;
+ res = listen(fd[0], 1);
+ if (res < 0)
+ goto close_fd_1;
+ res = connect(fd[1], (struct sockaddr *)&addr, len);
+ if (res < 0)
+ goto close_fd_1;
+ res = accept(fd[0], NULL, NULL);
+ if (res < 0)
+ goto close_fd_1;
+ close(fd[0]);
+ fd[0] = res;
+ return 0;
+
+close_fd_1:
+ close(fd[1]);
+
+close_fd_0:
+ close(fd[0]);
+
+err:
+ return -1;
+}
+
+int helper_thread_create(struct fio_sem *startup_sem, struct sk_out *sk_out)