asmlinkage int sys_clone(struct pt_regs regs) {

unsigned long clone_flags; unsigned long newsp;

int _user *parent_tidptr, *child_tidptr;

clone_flags = regs.ebx; newsp = regs.ecx;

newsp = regs.esp;

return do_fork(clone_flags, newsp, &regs, 0, parent_tidptr, child_tidptr);

The clone flags are no longer permanently set but can be passed to the system call as parameters in various registers. Thus, the first part of the function deals with extracting these parameters. Also, the stack of the parent process is not copied; instead, a new address (newsp) can be specified for it. (This is required to generate threads that share the address space with the parent process but use their own stack in this address space.) Two pointers (parent_tidptr and child_tidptr) in userspace are also specified for purposes of communication with thread libraries. Their meaning is discussed in Section 2.4.1.

Continue reading here: Implementation ofdofork

Was this article helpful?

0 0