Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] reading from large or "infinite" source in multio



On Wed, Nov 15, 2023 at 8:58 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> > > > > read foo < <(read bar; echo $bar) </dev/tty
> >
> > ... the multio loop is still reading /dev/tty and won't discover
> > until its I/O buffers fill up that "read foo" isn't consuming any more
> > input.

I fact it never notices then, either.

> Replace /dev/tty with /dev/zero and we're back to the unkillable loop.

Why not this?  Any reason that errors from write_loop() should be ignored?
diff --git a/Src/exec.c b/Src/exec.c
index 97823760f..1bbefd985 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2302,7 +2302,8 @@ closemn(struct multio **mfds, int fd, int type)
 			break;
 		}
 		for (i = 0; i < mn->ct; i++)
-		    write_loop(mn->fds[i], buf, len);
+		    if (write_loop(mn->fds[i], buf, len) < 0)
+			break;
 	    }
 	} else {
 	    /* cat process */
@@ -2314,7 +2315,8 @@ closemn(struct multio **mfds, int fd, int type)
 			else
 			    break;
 		    }
-		    write_loop(mn->pipe, buf, len);
+		    if (write_loop(mn->pipe, buf, len) < 0)
+			break;
 		}
 	}
 	_exit(0);


Messages sorted by: Reverse Date, Date, Thread, Author