ankursaxena
May 6th, 2004, 04:07 PM
Hi, I had a small question about forking a process.
I am reading someone's code who in his application creates a chunk of memory and say allocates it to variable ptr, now after that is done, he forks about 50 times and runs a function call passing the ptr pointer to it in the child processes...
now my question is, for all the 50 child processes...the ptr will be pointing to a different address in memory?(since they should get their own data segment) or is it the same mem?
Also if one of the child processes do a free on the ptr that was passed to the function call running there, will it affect any of the other processes??
I was a little confised on this.
thanx for all the help in advance.
Ankur
I am reading someone's code who in his application creates a chunk of memory and say allocates it to variable ptr, now after that is done, he forks about 50 times and runs a function call passing the ptr pointer to it in the child processes...
now my question is, for all the 50 child processes...the ptr will be pointing to a different address in memory?(since they should get their own data segment) or is it the same mem?
Also if one of the child processes do a free on the ptr that was passed to the function call running there, will it affect any of the other processes??
I was a little confised on this.
thanx for all the help in advance.
Ankur