From 058c79758d5fbee56e7849499a3e6ab4fba00600 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 14 Apr 2010 00:46:32 +0200 Subject: win32: ash: evalpipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy --- shell/ash.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/shell/ash.c b/shell/ash.c index a1bfd90f1..c80c1411d 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -8894,9 +8894,35 @@ expredir(union node *n) * of the shell, which make the last process in a pipeline the parent * of all the rest.) */ +#if ENABLE_PLATFORM_MINGW32 +static void +forkshell_evalpipe(struct forkshell *fs) +{ + union node *n = fs->n; + int flags = fs->flags; + int prevfd = fs->fd[2]; + int pip[2] = {fs->fd[0], fs->fd[1]}; + + TRACE(("ash: subshell: %s\n",__PRETTY_FUNCTION__)); + INT_ON; + if (pip[1] >= 0) { + close(pip[0]); + } + if (prevfd > 0) { + dup2(prevfd, 0); + close(prevfd); + } + if (pip[1] > 1) { + dup2(pip[1], 1); + close(pip[1]); + } + evaltreenr(n, flags); +} +#endif static void evalpipe(union node *n, int flags) { + IF_PLATFORM_MINGW32(struct forkshell fs); struct job *jp; struct nodelist *lp; int pipelen; @@ -8920,6 +8946,17 @@ evalpipe(union node *n, int flags) ash_msg_and_raise_error("pipe call failed"); } } +#if ENABLE_PLATFORM_MINGW32 + memset(&fs, 0, sizeof(fs)); + fs.fp = forkshell_evalpipe; + fs.flags = flags; + fs.n = lp->n; + fs.fd[0] = pip[0]; + fs.fd[1] = pip[1]; + fs.fd[2] = prevfd; + if (spawn_forkshell(jp, &fs, n->npipe.pipe_backgnd) < 0) + ash_msg_and_raise_error("unable to spawn shell"); +#endif if (forkshell(jp, lp->n, n->npipe.pipe_backgnd) == 0) { INT_ON; if (pip[1] >= 0) { @@ -13271,6 +13308,7 @@ static const forkpoint_fn forkpoints[] = { forkshell_openhere, forkshell_evalbackcmd, forkshell_evalsubshell, + forkshell_evalpipe, NULL }; -- cgit v1.2.3-55-g6feb