diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-14 00:46:32 +0200 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-20 19:14:52 +0200 |
commit | 058c79758d5fbee56e7849499a3e6ab4fba00600 (patch) | |
tree | 1781b1cc69e40ddc90ce6150b4146a6e67662752 /shell | |
parent | a2bcc7d62fee2e530ca150d7f185f122887608e8 (diff) | |
download | busybox-w32-058c79758d5fbee56e7849499a3e6ab4fba00600.tar.gz busybox-w32-058c79758d5fbee56e7849499a3e6ab4fba00600.tar.bz2 busybox-w32-058c79758d5fbee56e7849499a3e6ab4fba00600.zip |
win32: ash: evalpipe
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 38 |
1 files changed, 38 insertions, 0 deletions
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) | |||
8894 | * of the shell, which make the last process in a pipeline the parent | 8894 | * of the shell, which make the last process in a pipeline the parent |
8895 | * of all the rest.) | 8895 | * of all the rest.) |
8896 | */ | 8896 | */ |
8897 | #if ENABLE_PLATFORM_MINGW32 | ||
8898 | static void | ||
8899 | forkshell_evalpipe(struct forkshell *fs) | ||
8900 | { | ||
8901 | union node *n = fs->n; | ||
8902 | int flags = fs->flags; | ||
8903 | int prevfd = fs->fd[2]; | ||
8904 | int pip[2] = {fs->fd[0], fs->fd[1]}; | ||
8905 | |||
8906 | TRACE(("ash: subshell: %s\n",__PRETTY_FUNCTION__)); | ||
8907 | INT_ON; | ||
8908 | if (pip[1] >= 0) { | ||
8909 | close(pip[0]); | ||
8910 | } | ||
8911 | if (prevfd > 0) { | ||
8912 | dup2(prevfd, 0); | ||
8913 | close(prevfd); | ||
8914 | } | ||
8915 | if (pip[1] > 1) { | ||
8916 | dup2(pip[1], 1); | ||
8917 | close(pip[1]); | ||
8918 | } | ||
8919 | evaltreenr(n, flags); | ||
8920 | } | ||
8921 | #endif | ||
8897 | static void | 8922 | static void |
8898 | evalpipe(union node *n, int flags) | 8923 | evalpipe(union node *n, int flags) |
8899 | { | 8924 | { |
8925 | IF_PLATFORM_MINGW32(struct forkshell fs); | ||
8900 | struct job *jp; | 8926 | struct job *jp; |
8901 | struct nodelist *lp; | 8927 | struct nodelist *lp; |
8902 | int pipelen; | 8928 | int pipelen; |
@@ -8920,6 +8946,17 @@ evalpipe(union node *n, int flags) | |||
8920 | ash_msg_and_raise_error("pipe call failed"); | 8946 | ash_msg_and_raise_error("pipe call failed"); |
8921 | } | 8947 | } |
8922 | } | 8948 | } |
8949 | #if ENABLE_PLATFORM_MINGW32 | ||
8950 | memset(&fs, 0, sizeof(fs)); | ||
8951 | fs.fp = forkshell_evalpipe; | ||
8952 | fs.flags = flags; | ||
8953 | fs.n = lp->n; | ||
8954 | fs.fd[0] = pip[0]; | ||
8955 | fs.fd[1] = pip[1]; | ||
8956 | fs.fd[2] = prevfd; | ||
8957 | if (spawn_forkshell(jp, &fs, n->npipe.pipe_backgnd) < 0) | ||
8958 | ash_msg_and_raise_error("unable to spawn shell"); | ||
8959 | #endif | ||
8923 | if (forkshell(jp, lp->n, n->npipe.pipe_backgnd) == 0) { | 8960 | if (forkshell(jp, lp->n, n->npipe.pipe_backgnd) == 0) { |
8924 | INT_ON; | 8961 | INT_ON; |
8925 | if (pip[1] >= 0) { | 8962 | if (pip[1] >= 0) { |
@@ -13271,6 +13308,7 @@ static const forkpoint_fn forkpoints[] = { | |||
13271 | forkshell_openhere, | 13308 | forkshell_openhere, |
13272 | forkshell_evalbackcmd, | 13309 | forkshell_evalbackcmd, |
13273 | forkshell_evalsubshell, | 13310 | forkshell_evalsubshell, |
13311 | forkshell_evalpipe, | ||
13274 | NULL | 13312 | NULL |
13275 | }; | 13313 | }; |
13276 | 13314 | ||