Get fork() working on Windows
This is done without using Microsoft's internal APIs. MAP_PRIVATE mappings are copied to the subprocess via a pipe, since Microsoft doesn't want us to have proper COW pages. MAP_SHARED mappings are remapped without needing to do any copying. Global variables need copying along with the stack and the whole heap of anonymous mem. This actually improves the reliability of the redbean http server although one shouldn't expect 10k+ connections on a home computer that isn't running software built to serve like Linux or FreeBSD.
This commit is contained in:
11
ape/ape.S
11
ape/ape.S
@ -225,9 +225,14 @@ pc: cld
|
||||
3: call pcread
|
||||
dec %di
|
||||
jnz 3b
|
||||
6: mov %ax,XLM(LOADSTATE)+0
|
||||
mov %cx,XLM(LOADSTATE)+2
|
||||
mov %dx,XLM(LOADSTATE)+4
|
||||
6: mov $XLM(LOADSTATE),%di # ax,cx,dx,es
|
||||
stosw
|
||||
xchg %cx,%ax
|
||||
stosw
|
||||
xchg %dx,%ax
|
||||
stosw
|
||||
mov %es,%ax
|
||||
stosw
|
||||
ljmp $0,$REAL(realmodeloader)
|
||||
.endfn pc,globl,hidden
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@
|
||||
#define XLM_BADIDT 0x2230
|
||||
#define XLM_BADIDT_SIZE 6
|
||||
#define XLM_LOADSTATE 0x2240
|
||||
#define XLM_LOADSTATE_SIZE 6
|
||||
#define XLM_LOADSTATE_SIZE 8
|
||||
#define XLM_SIZE ROUNDUP(XLM_LOADSTATE + XLM_LOADSTATE_SIZE, 0x1000)
|
||||
#define IMAGE_BASE_REAL (XLM_BASE_REAL + XLM_SIZE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user