thread_group: pgid: inherit from parent

Inherit the process-group ID from the parent. If there is no parent
specified then the pgid is the same as the tgid.
This commit is contained in:
Matthew Leach
2026-01-15 19:32:01 +00:00
parent 1e91c60f0b
commit 6fc1990597

View File

@@ -62,7 +62,12 @@ impl ThreadGroupBuilder {
pub fn build(self) -> Arc<ThreadGroup> {
let ret = Arc::new(ThreadGroup {
tgid: self.tgid,
pgid: SpinLock::new(Pgid(self.tgid.value())),
pgid: SpinLock::new(
self.parent
.as_ref()
.map(|x| *x.pgid.lock_save_irq())
.unwrap_or_else(|| Pgid(self.tgid.value())),
),
sid: SpinLock::new(Sid(self.tgid.value())),
parent: SpinLock::new(self.parent.as_ref().map(Arc::downgrade)),
umask: SpinLock::new(self.umask.unwrap_or(0)),