aboutsummaryrefslogtreecommitdiffstats
path: root/ports/linux/newclone/guts/clone.c
blob: ee6fc09d6cb572e28768bba3de5654fcd7b16a08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* 
 * Copyright (c) 2008-2011 Wind River Systems; see
 * guts/COPYRIGHT for information.
 *
 * static int
 * clone(...) {
 *      ....
 */
	/* 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 create an intermediate function,
	 * wrap_clone_child, which does this fix up.
	 */

	struct clone_args * myargs = malloc(sizeof(struct clone_args));

	myargs->fn = fn;
	myargs->flags = flags;
	myargs->arg = arg;

	/* call the real syscall */
	rc = (*real_clone)(wrap_clone_child, child_stack, flags, myargs, pid, tls, ctid);

	/* If we're not sharing memory, we need to free myargs in the parent */
	if (!(flags & CLONE_VM))
		free(myargs);

/*	...
 *	return rc;
 * }
 */