long do_fork(unsigned long clone_flags, unsigned long stack_start, struct pt_regs *regs, unsigned long stack_size, int __user *parent_tidptr, int _user *child_tidptr)
The function requires the following arguments:
□ A flag set (clone_flags) to specify duplication properties. The low byte specifies the signal number to be sent to the parent process when the child process terminates. The higher bytes hold various constants discussed below.
□ The start address of the user mode stack (start_stack) to be used.
□ A pointer to the register set holding the call parameters in raw form (regs). The data type used is the architecture-specific struct pt_regs structure, which holds all registers in the order in which they are saved on the kernel stack when a system call is executed (more information is provided in Appendix A).
□ The size of the user mode stack (stack_size). This parameter is usually unnecessary and set to 0.
□ Two pointers to addresses in userspace (parent_tidptr and child_tidptr) that hold the TIDs of the parent and child processes. They are needed for the thread implementation of the NPTL (Native Posix Threads Lilbrary) library. I discuss their meaning below.
The different fork variants are distinguished primarily by means of the flag set. On most architectures,10 the classical fork call is implemented in the same way as on IA-32 processors.
10Exception: Sparc(64) systems that access do_fork via sparc_do_fork. IA-64 kernels only provide a single system call, sys_clone2, which is used to implement fork, vfork, and clone in userspace. Both sys_clone2 and sparc_do_fork eventually rely on do_fork.
Continue reading here: Archx86kernelprocess32c
Was this article helpful?