I have read here that it is mandatory for a process group to belong to a session.
But is it also mandatory for a process to belong to a process group?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
I think it is not so much "mandatory" as it is "unavoidable". A new process is automatically a member of its parent's process group. The only way to leave the process group is to either exit, or create a process group, in which case the creator is automatically moved from its current group to the newly created group. (Note that a new group can be created either by creating a new session or by creating a new group in the current session.)
(The same would be true of process groups; a new process group is created within the current session or as the initial group of a new session. There's no way to create a "naked" process group.)