From: Michael Tremer Date: Sun, 6 Oct 2024 13:59:09 +0000 (+0000) Subject: pty: Terminate if we encountered an error X-Git-Tag: 0.9.30~1136 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a01644e448dee91b20f0e7f39c73aa1e86c81aaa;p=pakfire.git pty: Terminate if we encountered an error Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pty.c b/src/libpakfire/pty.c index 4c09fc4d1..d00acc2f1 100644 --- a/src/libpakfire/pty.c +++ b/src/libpakfire/pty.c @@ -291,7 +291,7 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) { 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 @@ -307,7 +307,7 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) { 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 @@ -320,7 +320,7 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) { 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 @@ -336,7 +336,7 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) { 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 @@ -350,6 +350,10 @@ static int pakfire_pty_forward(struct pakfire_pty* pty) { return pakfire_pty_done(pty, 0); return 0; + +ERROR: + // Terminate if we have encountered an error + return pakfire_pty_done(pty, r); } /*