From 9912f3a537d96b41ae2b76d90215971e39f24a7e Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 3 Apr 2019 21:20:08 -0400 Subject: __clone(): properly handle four-argument (vfork mode) invocations. --- src/thread/nt32/clone.c | 14 ++++++++++++++ src/thread/nt64/clone.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src') diff --git a/src/thread/nt32/clone.c b/src/thread/nt32/clone.c index f5ad5f8..12d7e5e 100644 --- a/src/thread/nt32/clone.c +++ b/src/thread/nt32/clone.c @@ -1,4 +1,7 @@ +#define _GNU_SOURCE + #include +#include /* take advantage of i686 vararg abi */ #define __clone ____clone @@ -56,6 +59,17 @@ int __clone( pfn_clone = (__sys_clone *)(__syscall_vtbl[SYS_clone]); + if (flags == CLONE_VM|CLONE_VFORK|SIGCHLD) { + regs.sbase = 0; + regs.slimit = 0; + regs.sbottom = 0; + + return (int)pfn_clone( + flags, + child_stack, + 0,0,®s); + } + pthread = (pthread_t)pthread_self_addr; regs.sbase = (unsigned long)pthread->stack; regs.slimit = regs.sbase - pthread->stack_size; diff --git a/src/thread/nt64/clone.c b/src/thread/nt64/clone.c index c3a968b..6f11d17 100644 --- a/src/thread/nt64/clone.c +++ b/src/thread/nt64/clone.c @@ -1,4 +1,7 @@ +#define _GNU_SOURCE + #include +#include /* take advantage of winnt's x64 vararg abi */ #define __clone ____clone @@ -60,6 +63,17 @@ hidden int __clone( pfn_clone = (__sys_clone *)(__syscall_vtbl[SYS_clone]); + if (flags == CLONE_VM|CLONE_VFORK|SIGCHLD) { + regs.sbase = 0; + regs.slimit = 0; + regs.sbottom = 0; + + return (int)pfn_clone( + flags, + child_stack, + 0,0,®s); + } + pthread = (pthread_t)pthread_self_addr; regs.sbase = (unsigned long)pthread->stack; regs.slimit = regs.sbase - pthread->stack_size; -- cgit v1.2.3