r = pakfire_pty_fill_buffer(pty, pty->stdin.fd, &pty->stdin);
if (r < 0) {
CTX_ERROR(pty->ctx, "Failed reading from standard input: %s\n", strerror(-r));
- return r;
+ goto ERROR;
}
// We are done reading for now
r = pakfire_pty_drain_buffer(pty, pty->master.fd, &pty->stdin);
if (r < 0) {
CTX_ERROR(pty->ctx, "Failed writing to the PTY: %s\n", strerror(-r));
- return r;
+ goto ERROR;
}
// We are done writing for now
r = pakfire_pty_fill_buffer(pty, pty->master.fd, &pty->stdout);
if (r < 0) {
CTX_ERROR(pty->ctx, "Failed reading from the PTY: %s\n", strerror(-r));
- return r;
+ goto ERROR;
}
// We are done reading for now
r = pakfire_pty_drain_buffer(pty, pty->stdout.fd, &pty->stdout);
if (r < 0) {
CTX_ERROR(pty->ctx, "Failed writing to standard output: %s\n", strerror(-r));
- return r;
+ goto ERROR;
}
// We are done writing for now
return pakfire_pty_done(pty, 0);
return 0;
+
+ERROR:
+ // Terminate if we have encountered an error
+ return pakfire_pty_done(pty, r);
}
/*