diff options
Diffstat (limited to 'ports/linux/newclone/pseudo_wrappers.c')
-rw-r--r-- | ports/linux/newclone/pseudo_wrappers.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/ports/linux/newclone/pseudo_wrappers.c b/ports/linux/newclone/pseudo_wrappers.c index dd44408..9dbac42 100644 --- a/ports/linux/newclone/pseudo_wrappers.c +++ b/ports/linux/newclone/pseudo_wrappers.c @@ -10,6 +10,34 @@ ap) { return 0; } +struct clone_args { + int (*fn)(void *); + int flags; + void *arg; +}; + +int wrap_clone_child(void *args) { + struct clone_args *clargs = args; + + int (*fn)(void *) = clargs->fn; + int flags = clargs->flags; + void *arg = clargs->arg; + + /* We always free in the client */ + free(clargs); + + if (!(flags & CLONE_VM)) { + pseudo_setupenv(); + if (!pseudo_get_value("PSEUDO_UNLOAD")) { + pseudo_reinit_libpseudo(); + } else { + pseudo_dropenv(); + } + } + + return fn(arg); +} + int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...) { sigset_t saved; @@ -42,11 +70,6 @@ clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ...) { int save_errno; int save_disabled = pseudo_disabled; - /* because clone() doesn't actually continue in this function, we - * can't check the return and fix up environment variables in the - * child. Instead, we have to temporarily do any fixup, then possibly - * undo it later. UGH! - */ #include "guts/clone.c" |