aboutsummaryrefslogtreecommitdiff
path: root/shell/ash.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-14 00:45:28 +0200
committerNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-04-20 19:14:51 +0200
commit9b4b51d0530d804c178d8531d60cb0335c22085c (patch)
tree07d2fd4f32d0aafb003a2a60825826cc0e7e76b6 /shell/ash.c
parent9eb5b4659d24fcceaa4761c3dfa2c7b1d5e60e81 (diff)
downloadbusybox-w32-9b4b51d0530d804c178d8531d60cb0335c22085c.tar.gz
busybox-w32-9b4b51d0530d804c178d8531d60cb0335c22085c.tar.bz2
busybox-w32-9b4b51d0530d804c178d8531d60cb0335c22085c.zip
win32: ash: openhere
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c39
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 */
5094static void expandhere(union node *arg, int fd); 5094static void expandhere(union node *arg, int fd);
5095#if ENABLE_PLATFORM_MINGW32
5096static void
5097forkshell_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
5095static int 5122static int
5096openhere(union node *redir) 5123openhere(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
13178static const forkpoint_fn forkpoints[] = { 13216static const forkpoint_fn forkpoints[] = {
13217 forkshell_openhere,
13179 NULL 13218 NULL
13180}; 13219};
13181 13220