From: Trent Huber Date: Thu, 4 Sep 2025 23:41:23 +0000 (-0400) Subject: Fix pipe error handling X-Git-Url: https://trenthuber.com/code?a=commitdiff_plain;h=9c91204f8a143c3d6a1c13c84bc6ad31b538d6fa;p=thus.git Fix pipe error handling --- diff --git a/src/run.c b/src/run.c index 375bf1f..c896062 100644 --- 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) {