From 5364221c96375acf96cf7914ef5be75eb174b7c1 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 14 Apr 2010 01:00:32 +0200 Subject: win32: ash: spawn_forkshell() 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 8802c1315..f320f26c3 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -112,6 +112,7 @@ struct forkshell { struct strlist *strlist; pid_t pid; }; +static int spawn_forkshell(struct job *jp, struct forkshell *fs, int mode); #endif /* ============ Hash table sizes. Configurable. */ @@ -13320,6 +13321,29 @@ int ash_main(int argc UNUSED_PARAM, char **argv) /* NOTREACHED */ } +/* FIXME: should consider running forkparent() and forkchild() */ +static int +spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) +{ + const char *argv[] = { "sh", "--forkshell", NULL, NULL }; + char buf[16]; + + struct forkshell *new; + new = forkshell_prepare(fs); + sprintf(buf, "%x", (unsigned int)new->hMapFile); + argv[2] = buf; + fs->pid = mingw_spawn_applet(P_NOWAIT, "sh", argv, + (const char *const *)environ); + CloseHandle(new->hMapFile); + UnmapViewOfFile(new); + if (fs->pid == -1) { + free(jp); + return -1; + } + forkparent(jp, fs->node, mode, fs->pid); + return fs->pid; +} + /* * forkshell_prepare() and friends * -- cgit v1.2.3-55-g6feb