]> git.ipfire.org Git - pakfire.git/commitdiff
pty: Terminate if we encountered an error
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 6 Oct 2024 13:59:09 +0000 (13:59 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 6 Oct 2024 13:59:09 +0000 (13:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pty.c

index 4c09fc4d119a4d98f16b6f5238bcb506e469e836..d00acc2f13194909db9d844a23e0f7ac689f32a2 100644 (file)
@@ -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);
 }
 
 /*