Kernelforkc

add_parent(p);

if (clone_flags & CLONE_NEWPID)

set_task_pgrp(p, task_pgrp_nr(current)); set_task_session(p, task_session_nr(current)); attach_pid(p, PIDTYPE_PGID, task_pgrp(current)); attach_pid(p, PIDTYPE_SID, task_session(current));

attach_pid(p, PIDTYPE_PID, pid); return p;

thread_group_leader checks only whether pid and tgid of the new process are identical. If so, the process is the leader of a thread group. In this case, some more work is necessary:

□ Recall that processes in a process namespace that is not the global namespace have their own init task. If a new PID namespace was opened by setting clone_newpid, this role must be assumed by the task that called clone.

□ The new process must be added to the current task group and session. This allows for bringing some of the functions discussed above to good use.

Finally, the PID itself is added to the ID network. This concludes the creation of a new process!

Continue reading here: Special Points When Generating Threads

Was this article helpful?

0 0