Changeset 2293 in kBuild for trunk/src/kash/shheap.c
- Timestamp:
- Feb 28, 2009 7:25:12 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shheap.c
r2292 r2293 137 137 #ifdef SHHEAP_IN_USE 138 138 139 # if K_OS == K_OS_WINDOWS 140 /** 141 * Copies the heap into the child process. 142 * 143 * @returns 0 on success, -1 and errno on failure. 144 * @param hChild Handle to the child process. 145 */ 146 int shheap_fork_copy_to_child(void *hChild) 147 { 148 shmemchunk *chunk; 149 shmtxtmp tmp; 150 int err = 0; 151 152 shmtx_enter(&g_sh_heap_mtx, &tmp); 153 154 for (chunk = g_sh_heap; chunk; chunk = chunk->next) 155 { 156 void *chld_chnk; 157 158 chld_chnk = (shmemchunk *)VirtualAllocEx(hChild, chunk, chunk->size, 159 MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); 160 if (chld_chnk != chunk) 161 { 162 err = GetLastError(); 163 fprintf(stderr, "shfork: VirtualAllocEx(,%p,%p,) -> %d\n", chunk, chunk->size, err); 164 break; 165 } 166 167 if (!WriteProcessMemory(hChild, chunk, chunk, chunk->size, NULL /* pNumberOfBytesWritten */)) 168 { 169 err = GetLastError(); 170 fprintf(stderr, "shfork: WriteProcessMemory(,%p,,%p,) -> %d\n", chunk, chunk->size, err); 171 break; 172 } 173 } 174 175 shmtx_leave(&g_sh_heap_mtx, &tmp); 176 177 if (!err) 178 return 0; 179 errno = EINVAL; 180 return -1; 181 } 182 # endif 183 184 139 185 /** 140 186 * Checks a heap chunk.
Note:
See TracChangeset
for help on using the changeset viewer.