]> Trent Huber's Code - thus.git/commitdiff
Fix pipe error handling
authorTrent Huber <trentmhuber@gmail.com>
Thu, 4 Sep 2025 23:41:23 +0000 (19:41 -0400)
committerTrent Huber <trentmhuber@gmail.com>
Thu, 4 Sep 2025 23:41:23 +0000 (19:41 -0400)
src/run.c

index 375bf1f9db9fe0bd7fee0e46f6c7293f3c765853..c8960621b9f6ab3ebeb437fb162c1fa986515a23 100644 (file)
--- a/src/run.c
+++ b/src/run.c
@@ -113,7 +113,11 @@ int run(struct context *c) {
                }
                exec(path, c);
            }
-           if (ispipestart) pipeid = cpid; else closepipe(c->prev);
+           if (ispipestart) pipeid = cpid;
+           else if (!closepipe(c->prev)) {
+               killpg(pipeid, SIGKILL);
+               return quit(c);
+           }
            jobid = pipeid;
        } else if (!c->r && isbuiltin(c->tokens)) cpid = 0;
        else if ((jobid = cpid = fork()) == -1) {