parent and child processes share the same stack.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All:

I am porting Linux to my r3000 cpu now and meet with a problem when the
init program is running. 

When the init process (pid=1) forks the first child (pid=7), the parent
process called copy_thread( ) which did the following assignment:
childregs->regs[29] = usp ( Here, usp is the parent's stack pointer)
(see arch/mips/kerenel/process.c).  So, the child and the parent share
the same stack.

After the fork, the parent called write_utmp_wtmp( ) which then called
memset(&utmp,0,sizeof(utmp)) and erased the stack. As we know, this
stack is shared by the parent and the child, the child will die when the
child is scheduled to run because the contents of the stack are all
zeros.

I think the stack should not be shared by the parent and the child after
anyone tries to modify the stack, that is, the child and parent should
have separete stacks. I searched the code and could not find the place
where the separation is given. 

Any help would be greatly appreciated.

Thanks,

Steven Liu

[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux