Re: clone testcases in LTP

From: Peter Chubb <peter_at_chubb.wattle.id.au>
Date: 2003-07-11 09:22:42
>>>>> "David" == David Mosberger <davidm@napali.hpl.hp.com> writes:

>>>>> On Thu, 10 Jul 2003 11:18:38 -0500, Nathan Straz <nstraz@sgi.com> said:
>>> /* int __clone2(int (*fn) (void *arg), void *child_stack_base, */
>>> /* size_t child_stack_size, int flags, void *arg, */ /* pid_t
>>> *parent_tid, void *tls, pid_t *child_tid) */

I'm not finding that clone2() works -- We get a segfault in the cloned
process when it returns.

This is the program:

#include <stdio.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>

int func(void *arg) { 
    fprintf(stderr, "In child\n"); 
    return 0;
} 
 
int main(void) 
{ 
        int pagesize = sysconf(_SC_PAGESIZE); 
        char *stack;
	int status;
        pid_t kidpid; 
 
#define STACKSIZE (pagesize*8) 
        stack = valloc(STACKSIZE); 
        if ((kidpid = __clone2(func, stack, STACKSIZE, SIGCHLD, NULL,
		    NULL,  NULL, NULL)) == -1) 
                perror("clone"); 
        else { 
                waitpid(kidpid, &status, __WALL);
                if (status) 
                   fprintf(stderr, "child failed: status %x\n", 
				   status); 
	} 
        return 0; 
}

I see:

In child
child failed: status b

where b translates to segfault.

Peter c


-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Jul 10 19:23:03 2003

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:16 EST