summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-04-03 21:20:08 -0400
committermidipix <writeonce@midipix.org>2019-04-03 21:20:08 -0400
commit9912f3a537d96b41ae2b76d90215971e39f24a7e (patch)
tree82086e2573cd10c0278ec7109af30998440e2e04
parent8576ddb6e5a39422b9ac18625954df47f44f302a (diff)
downloadmmglue-9912f3a537d96b41ae2b76d90215971e39f24a7e.tar.bz2
mmglue-9912f3a537d96b41ae2b76d90215971e39f24a7e.tar.xz
__clone(): properly handle four-argument (vfork mode) invocations.
-rw-r--r--src/thread/nt32/clone.c14
-rw-r--r--src/thread/nt64/clone.c14
2 files changed, 28 insertions, 0 deletions
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 <syscall.h>
+#include <sched.h>
/* 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,&regs);
+ }
+
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 <syscall.h>
+#include <sched.h>
/* 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,&regs);
+ }
+
pthread = (pthread_t)pthread_self_addr;
regs.sbase = (unsigned long)pthread->stack;
regs.slimit = regs.sbase - pthread->stack_size;