Subject: Re: fork1 and new stack
To: Emmanuel Dreyfus <>
From: Andrey Petrov <>
List: tech-kern
Date: 04/26/2002 14:37:42
On Fri, Apr 26, 2002 at 11:14:24PM +0200, Emmanuel Dreyfus wrote:
> > Having said that, I'd first try fork1 with exact parent's stack.
> > And I beleive in this case you don't need to allocate it.
> I cannot do this: parent and child share the same address space: if they
> use the same stack, everythign will be screwed quickly.

I had to say 'parent's stack map' may be, I didn't mean sp. You should
point sp to different locations, as you have it now. Make sure it's
inside parents's stack area though.
Your child's sp is way below the parent's sp, so even they can eventually
overlap it's not possible at fork time. You just (re)use the same stack area
which already exists in your parent but different location inside there.

> > I suspect that your child process havn't reached user-space. So
> > I'd tried to catch it in kernel.
> How would you do this? Calling Debugger() (where?) and once you catch
> it, I cannot break on SIGSEGV delivery, like in gdb. Can I?

You'll need to instrument your kernel accordingly. Store your child pid
in static variable and call Debugger along the return path if your
curproc's pid matches for example. Or set breakpoints when youre in ddb.