diff options
-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 6a1e78e19..3dfe30006 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. */ |
@@ -13321,6 +13322,29 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
13321 | /* NOTREACHED */ | 13322 | /* NOTREACHED */ |
13322 | } | 13323 | } |
13323 | 13324 | ||
13325 | /* FIXME: should consider running forkparent() and forkchild() */ | ||
13326 | static int | ||
13327 | spawn_forkshell(struct job *jp, struct forkshell *fs, int mode) | ||
13328 | { | ||
13329 | const char *argv[] = { "sh", "--forkshell", NULL, NULL }; | ||
13330 | char buf[16]; | ||
13331 | |||
13332 | struct forkshell *new; | ||
13333 | new = forkshell_prepare(fs); | ||
13334 | sprintf(buf, "%x", (unsigned int)new->hMapFile); | ||
13335 | argv[2] = buf; | ||
13336 | fs->pid = mingw_spawn_applet(P_NOWAIT, "sh", argv, | ||
13337 | (const char *const *)environ); | ||
13338 | CloseHandle(new->hMapFile); | ||
13339 | UnmapViewOfFile(new); | ||
13340 | if (fs->pid == -1) { | ||
13341 | free(jp); | ||
13342 | return -1; | ||
13343 | } | ||
13344 | forkparent(jp, fs->node, mode, fs->pid); | ||
13345 | return fs->pid; | ||
13346 | } | ||
13347 | |||
13324 | /* | 13348 | /* |
13325 | * forkshell_prepare() and friends | 13349 | * forkshell_prepare() and friends |
13326 | * | 13350 | * |