+
+ close(p[1]);
+ rbuf_init(&in, p[0], tal_arr(ctx, char, 4096), 4096);
+ if (!rbuf_read_str(&in, 0, do_tal_realloc) && errno)
+ in.buf = tal_free(in.buf);
+
+ /* This shouldn't fail... */
+ if (waitpid(pid, &status, 0) != pid)
+ err(1, "Failed to wait for child");
+
+ ms = time_to_msec(time_between(time_now(), start));
+ if (ms > *timeout_ms)
+ *timeout_ms = 0;
+ else
+ *timeout_ms -= ms;
+ close(p[0]);
+ if (tools_verbose) {
+ printf("%s", in.buf);
+ printf("Finished: %u ms, %s %u\n", ms,
+ WIFEXITED(status) ? "exit status" : "killed by signal",
+ WIFEXITED(status) ? WEXITSTATUS(status)
+ : WTERMSIG(status));
+ }
+ *ok = (WIFEXITED(status) && WEXITSTATUS(status) == 0);
+ return in.buf;