summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed T. Crigler <crigler@gmail.com>2025-06-19 20:03:57 -0700
committerNed T. Crigler <crigler@gmail.com>2025-06-19 20:30:31 -0700
commite34e2bb3c703aa8c47d85ba4b4a86f6ae5dc0404 (patch)
tree134ffc985ae99e6b09cb76ad9ea2315c57150404
parentdc84bf8b0f70af92f894209d2cf68eaff55db9f0 (diff)
Handle partial reads of the execvp error string
It is possible that reading the entire error string requires multiple read() calls.
-rw-r--r--master.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/master.c b/master.c
index 75f4926..6d6d4d2 100644
--- a/master.c
+++ b/master.c
@@ -672,7 +672,12 @@ master_main(char **argv, int waitattach, int dontfork)
len = read(fd[0], buf, sizeof(buf));
if (len > 0)
{
- write_buf_or_fail(2, buf, len);
+ do
+ {
+ write_buf_or_fail(2, buf, len);
+ len = read(fd[0], buf, sizeof(buf));
+ } while (len > 0);
+
kill(pid, SIGTERM);
return 1;
}