Browse Source

[LibOS] Emulate clone(CLONE_VFORK | CLONE_VM | SIGCHLD) as vfork()

Some runtimes use clone(CLONE_VFORK | CLONE_VM | SIGCHLD) for vfork().
Isaku Yamahata 5 years ago
parent
commit
ec4a3f7bb5
1 changed files with 7 additions and 0 deletions
  1. 7 0
      LibOS/shim/src/sys/shim_clone.c

+ 7 - 0
LibOS/shim/src/sys/shim_clone.c

@@ -171,6 +171,13 @@ int shim_do_clone (int flags, void * user_stack_addr, int * parent_tidptr,
     int * set_parent_tid = NULL;
     int ret = 0;
 
+    /* special case for vfork. some runtime uses clone() for vfork */
+    if (flags == (CLONE_VFORK | CLONE_VM | SIGCHLD) &&
+        user_stack_addr == NULL && parent_tidptr == NULL &&
+        child_tidptr == NULL && tls == NULL) {
+        return shim_do_vfork();
+    }
+
     assert((flags & ~(CLONE_PARENT_SETTID|CLONE_CHILD_SETTID|
                       CLONE_CHILD_CLEARTID|CLONE_SETTLS|
                       CLONE_VM|CLONE_FILES|