return pakfire_jail_output(exec->jail, fd, events, exec->streams.stderr);
}
+static int pakfire_jail_drain(sd_event_source* source, void* data) {
+ struct pakfire_jail_exec* exec = data;
+ struct pakfire_jail* self = exec->jail;
+ int r;
+
+ DEBUG(self->ctx, "Draining the pipes...\n");
+
+ // Drain standard output
+ if (exec->pipes.stdout[0] >= 0) {
+ r = pakfire_jail_stdout(source, exec->pipes.stdout[0], EPOLLIN, data);
+ if (r < 0)
+ return r;
+ }
+
+ // Drain standard error
+ if (exec->pipes.stderr[0] >= 0) {
+ r = pakfire_jail_stderr(source, exec->pipes.stderr[0], EPOLLIN, data);
+ if (r < 0)
+ return r;
+ }
+
+ return 0;
+}
+
/*
This function replaces any logging in the child process.
}
}
+ // Drain the pipes when exiting the loop
+ r = sd_event_add_exit(ctx->loop, NULL, pakfire_jail_drain, ctx);
+ if (r < 0) {
+ ERROR(jail->ctx, "Failed to register the drain event: %s\n", strerror(-r));
+ return r;
+ }
+
// Setup logging
r = pakfire_log_stream_in_parent(ctx->streams.INFO, ctx->loop);
if (r)