diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-14 01:00:32 +0200 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-04-20 19:14:49 +0200 |
commit | 5364221c96375acf96cf7914ef5be75eb174b7c1 (patch) | |
tree | c23ca606b39d027567ed3385ee765659c0d99053 /shell | |
parent | 0a871637121709f44fbc006790dc84ef7a086c5a (diff) | |
download | busybox-w32-5364221c96375acf96cf7914ef5be75eb174b7c1.tar.gz busybox-w32-5364221c96375acf96cf7914ef5be75eb174b7c1.tar.bz2 busybox-w32-5364221c96375acf96cf7914ef5be75eb174b7c1.zip |
win32: ash: spawn_forkshell()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 { | |||
112 | struct strlist *strlist; | 112 | struct strlist *strlist; |
113 | pid_t pid; | 113 | pid_t pid; |
114 | }; | 114 | }; |
115 | static int spawn_forkshell(struct job *jp, struct forkshell *fs, int mode); | ||
115 | #endif | 116 | #endif |
116 | 117 | ||
117 | /* ============ Hash table sizes. Configurable. */ | 118 | /* ============ Hash table sizes. Configurable. */ |
@@ -13320,6 +13321,29 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13320 | /* NOTREACHED */ | 13321 | /* NOTREACHED */ |
13321 | } | 13322 | } |
13322 | 13323 | ||
13324 | /* FIXME: should consider running forkparent() and forkchild() */ | ||
13325 | static int | ||
13326 | spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) | ||
13327 | { | ||
13328 | const char *argv[] = { "sh", "--forkshell", NULL, NULL }; | ||
13329 | char buf[16]; | ||
13330 | |||
13331 | struct forkshell *new; | ||
13332 | new = forkshell_prepare(fs); | ||
13333 | sprintf(buf, "%x", (unsigned int)new->hMapFile); | ||
13334 | argv[2] = buf; | ||
13335 | fs->pid = mingw_spawn_applet(P_NOWAIT, "sh", argv, | ||
13336 | (const char *const *)environ); | ||
13337 | CloseHandle(new->hMapFile); | ||
13338 | UnmapViewOfFile(new); | ||
13339 | if (fs->pid == -1) { | ||
13340 | free(jp); | ||
13341 | return -1; | ||
13342 | } | ||
13343 | forkparent(jp, fs->node, mode, fs->pid); | ||
13344 | return fs->pid; | ||
13345 | } | ||
13346 | |||
13323 | /* | 13347 | /* |
13324 | * forkshell_prepare() and friends | 13348 | * forkshell_prepare() and friends |
13325 | * | 13349 | * |