From b16c039dc21faa0d68a0ba45eab857895e82439b Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Wed, 16 Mar 2016 03:06:03 +0100 Subject: [PATCH] fork in repl as a tree This fix the bug in the last improvement (pipe mail through show). In the first patch repl only waits for one child, now the tree causes that both childs finished befor repl continues. --- uip/repl.c | 69 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/uip/repl.c b/uip/repl.c index 9006dec..8a40543 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -703,7 +703,6 @@ replfilter(FILE *in, FILE *out, char *filter) { int pid, pid_show, n; int mailpipe[2]; - char *errstr; if (filter == NULL) return; @@ -714,51 +713,51 @@ replfilter(FILE *in, FILE *out, char *filter) rewind(in); lseek(fileno(in), (off_t) 0, SEEK_SET); - if (pipe(mailpipe) == -1) { - adios(EX_OSERR, "pipe", "can't create pipe"); - } - - switch (pid_show = fork()) { - case NOTOK: - adios(EX_OSERR, "fork", "unable to"); - - case OK: - dup2(fileno(in), fileno(stdin)); - dup2(mailpipe[1], fileno(stdout)); - for (n=3; n