Changeset 2416 for trunk/src/kash/shfork-win.c
- Timestamp:
- Sep 14, 2010, 2:30:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shfork-win.c
r2377 r2416 6 6 #include <string.h> 7 7 #include <locale.h> 8 #include <assert.h> 8 9 #include "shinstance.h" 9 10 #include <Windows.h> … … 29 30 30 31 /* in shforkA-win.asm: */ 32 extern pid_t shfork_do_it(shinstance *psh); 31 33 extern void shfork_resume(void *cur, void *base, void *limit); 32 34 … … 34 36 void *shfork_maybe_forked(int argc, char **argv, char **envp); 35 37 extern int shfork_body(shinstance *psh, void *stack_ptr); 36 37 38 /*** 38 extern void init_syntax(void); 39 40 41 /** 39 42 * Called by shforkA-win.asm to check whether we're a forked child 40 43 * process or not. … … 64 67 { 65 68 char *stack; 66 shheap_init(); 67 stack = (char *)sh_malloc(NULL, SHFORK_STACK_SIZE) + SHFORK_STACK_SIZE; 68 g_stack_base = stack + SHFORK_STACK_SIZE; 69 g_stack_limit = stack; 69 shheap_init(NULL); 70 g_stack_limit = stack = (char *)sh_malloc(NULL, SHFORK_STACK_SIZE); 71 g_stack_base = stack += SHFORK_STACK_SIZE; 70 72 return stack; 71 73 } … … 83 85 g_stack_base = shfork_string_to_ptr(argv[5], argv[0], "--stack-base"); 84 86 g_stack_limit = shfork_string_to_ptr(argv[7], argv[0], "--stack-limit"); 87 assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base); 88 assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit); 85 89 86 90 /* … … 137 141 } 138 142 139 /*** 143 /** 144 * Do the fork. 145 * @returns same as fork(). 146 * @param psh The shell that's forking. 147 */ 148 int shfork_do(shinstance *psh) 149 { 150 /* save globals */ 151 void *pheap_head = shheap_get_head(); 152 pid_t pid = shfork_do_it(psh); 153 if (pid == 0) 154 { 155 /* reinit stuff, only the heap is copied! */ 156 shthread_set_shell(psh); 157 shheap_init(pheap_head); 158 setlocale(LC_ALL, ""); 159 init_syntax(); 160 } 161 return pid; 162 } 163 164 /** 140 165 * Create the child process making sure it inherits all our handles, 141 166 * copy of the forkable heap and kick it off. … … 156 181 DWORD cch; 157 182 int rc = 0; 183 184 assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base); 185 assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit); 158 186 159 187 /* … … 178 206 stack_ptr, g_stack_base, g_stack_limit); 179 207 szCmdLine[cch+1] = '\0'; 208 TRACE2((NULL, "shfork_body: szCmdLine=%s\n", szCmdLine)); 180 209 181 210 memset(&StrtInfo, '\0', sizeof(StrtInfo)); /* just in case. */
Note:
See TracChangeset
for help on using the changeset viewer.