diff options
| -rw-r--r-- | shell/ash.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index d21922f66..007009245 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -5092,11 +5092,39 @@ noclobberopen(const char *fname) | |||
| 5092 | */ | 5092 | */ |
| 5093 | /* openhere needs this forward reference */ | 5093 | /* openhere needs this forward reference */ |
| 5094 | static void expandhere(union node *arg, int fd); | 5094 | static void expandhere(union node *arg, int fd); |
| 5095 | #if ENABLE_PLATFORM_MINGW32 | ||
| 5096 | static void | ||
| 5097 | forkshell_openhere(struct forkshell *fs) | ||
| 5098 | { | ||
| 5099 | union node *redir = fs->n; | ||
| 5100 | int pip[2]; | ||
| 5101 | |||
| 5102 | pip[0] = fs->fd[0]; | ||
| 5103 | pip[1] = fs->fd[1]; | ||
| 5104 | |||
| 5105 | TRACE(("ash: subshell: %s\n",__PRETTY_FUNCTION__)); | ||
| 5106 | |||
| 5107 | close(pip[0]); | ||
| 5108 | ignoresig(SIGINT); //signal(SIGINT, SIG_IGN); | ||
| 5109 | ignoresig(SIGQUIT); //signal(SIGQUIT, SIG_IGN); | ||
| 5110 | ignoresig(SIGHUP); //signal(SIGHUP, SIG_IGN); | ||
| 5111 | ignoresig(SIGTSTP); //signal(SIGTSTP, SIG_IGN); | ||
| 5112 | signal(SIGPIPE, SIG_DFL); | ||
| 5113 | if (redir->type == NHERE) { | ||
| 5114 | size_t len = strlen(redir->nhere.doc->narg.text); | ||
| 5115 | full_write(pip[1], redir->nhere.doc->narg.text, len); | ||
| 5116 | } else /* NXHERE */ | ||
| 5117 | expandhere(redir->nhere.doc, pip[1]); | ||
| 5118 | _exit(EXIT_SUCCESS); | ||
| 5119 | } | ||
| 5120 | #endif | ||
| 5121 | |||
| 5095 | static int | 5122 | static int |
| 5096 | openhere(union node *redir) | 5123 | openhere(union node *redir) |
| 5097 | { | 5124 | { |
| 5098 | int pip[2]; | 5125 | int pip[2]; |
| 5099 | size_t len = 0; | 5126 | size_t len = 0; |
| 5127 | IF_PLATFORM_MINGW32(struct forkshell fs); | ||
| 5100 | 5128 | ||
| 5101 | if (pipe(pip) < 0) | 5129 | if (pipe(pip) < 0) |
| 5102 | ash_msg_and_raise_error("pipe call failed"); | 5130 | ash_msg_and_raise_error("pipe call failed"); |
| @@ -5107,6 +5135,16 @@ openhere(union node *redir) | |||
| 5107 | goto out; | 5135 | goto out; |
| 5108 | } | 5136 | } |
| 5109 | } | 5137 | } |
| 5138 | #if ENABLE_PLATFORM_MINGW32 | ||
| 5139 | memset(&fs, 0, sizeof(fs)); | ||
| 5140 | fs.fp = forkshell_openhere; | ||
| 5141 | fs.flags = 0; | ||
| 5142 | fs.n = redir; | ||
| 5143 | fs.fd[0] = pip[0]; | ||
| 5144 | fs.fd[1] = pip[1]; | ||
| 5145 | if (spawn_forkshell(NULL, &fs, FORK_NOJOB) < 0) | ||
| 5146 | ash_msg_and_raise_error("unable to spawn shell"); | ||
| 5147 | #endif | ||
| 5110 | if (forkshell((struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) { | 5148 | if (forkshell((struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) { |
| 5111 | /* child */ | 5149 | /* child */ |
| 5112 | close(pip[0]); | 5150 | close(pip[0]); |
| @@ -13176,6 +13214,7 @@ extern int etext(); | |||
| 13176 | 13214 | ||
| 13177 | #if ENABLE_PLATFORM_MINGW32 | 13215 | #if ENABLE_PLATFORM_MINGW32 |
| 13178 | static const forkpoint_fn forkpoints[] = { | 13216 | static const forkpoint_fn forkpoints[] = { |
| 13217 | forkshell_openhere, | ||
| 13179 | NULL | 13218 | NULL |
| 13180 | }; | 13219 | }; |
| 13181 | 13220 | ||
