NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: child process is not created using clone()
On Apr 15, 10:50am, amolpise15%gmail.com@localhost (amol pise) wrote:
-- Subject: Re: child process is not created using clone()
| Dear Christos,
|
| Thank you very much for your valuable inputs.
| I had installed NetBSD latest release 5.1 iso from the below link on vmware=
| .
| http://193.166.3.2/pub/NetBSD/iso/5.1/i386cd-5.1.iso
|
| But I noticed the same issue i.e. "Not able to create a child process
| using clone() if the executable build by linking with pthread
| library."
|
| As per your reply, it is not an issue on current NetBSD (MAIN).
| Does it mean this was the issue with the earlier NetBSD releases (<=3DNB
| 5.1) ? and is fixed in current (MAIN) ?
|
| If yes, can you please provide us the associated src changes ?
| I couldnt find any commit logs showing the same in CVS MAIN trunk.
|
| Awaiting your reply.
I really don't know why it fails for you. Could it be i386 related?
Or simple changes I made to the code?
christos
[5:18pm] 28>cc sample_clone.c
[5:19pm] 29>./a.out
child stack allocated = 0x7f7ffda01000
child stack = 0x7f7ffda03710
In child
[5:19pm] 30>cc -static sample_clone.c
[5:19pm] 31>./a.out
child stack allocated = 0x7f7ffde01000
child stack = 0x7f7ffde03710
In child
[5:19pm] 32>cc -pthread sample_clone.c
[5:19pm] 33>./a.out
child stack allocated = 0x7f7ffd801000
child stack = 0x7f7ffd803710
In child
[5:19pm] 34>cc -static -pthread sample_clone.c
[5:19pm] 35>./a.out
child stack allocated = 0x7f7ffde01000
child stack = 0x7f7ffde03710
In child
[5:19pm] 36>uname -a
NetBSD morden.NetBSD.org 5.1_STABLE NetBSD 5.1_STABLE (NBFTP) #15: Sun Apr 10
10:30:44 UTC 2011
root%franklin.NetBSD.org@localhost:/home/netbsd/5/amd64/kern-compile/NBFTP amd64
[5:19pm] 37>cat sample_clone.c
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <signal.h>
#include <err.h>
#define ALIGNMENT 0x08
int pid;
int
fun(void *arg)
{
printf("\n In child \n");
_exit(0);
}
int
main(void)
{
char *ch_stck, *ch_stck2;
int status;
if ((ch_stck = malloc(10000)) == NULL)
err(1, "malloc");
printf("child stack allocated = %p\n", ch_stck);
ch_stck2 = (void *)((intptr_t)(ch_stck + 10000) & ~(ALIGNMENT -1));
printf("child stack = %p\n", ch_stck2);
if ((pid = clone(fun, ch_stck2, SIGCHLD, NULL)) == -1)
err(1, "clone");
if ((wait(&status)) == -1)
err(1, "wait");
return 0;
}
Home |
Main Index |
Thread Index |
Old Index