10 if (swapcontext(&uc_child, &uc_main) != 0)
14 int main(int argc, char *argv[])
19 /* the default is that it fails */
20 if ((fp = fopen("conftestval", "w")) == NULL)
25 /* configure a child user-space context */
26 if ((stack = malloc(64*1024)) == NULL)
28 if (getcontext(&uc_child) != 0)
30 uc_child.uc_link = NULL;
31 uc_child.uc_stack.ss_sp = (char *)stack+(32*1024);
32 uc_child.uc_stack.ss_size = 32*1024;
33 uc_child.uc_stack.ss_flags = 0;
34 makecontext(&uc_child, child, 0);
36 /* switch into the user context */
37 if (swapcontext(&uc_main, &uc_child) != 0)
40 /* Fine, child came home */
41 if ((fp = fopen("conftestval", "w")) == NULL)
46 /* die successfully */