From a88680b76554ebac18d42d8d609984ecf95fdd86 Mon Sep 17 00:00:00 2001 From: Wim Date: Thu, 23 Feb 2023 13:09:02 +0100 Subject: [PATCH] Implement code review remarks --- pkg/sentry/fsimpl/devpts/line_discipline.go | 6 +----- pkg/sentry/fsimpl/devpts/terminal.go | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/sentry/fsimpl/devpts/line_discipline.go b/pkg/sentry/fsimpl/devpts/line_discipline.go index 3ca11a985..9b58051db 100644 --- a/pkg/sentry/fsimpl/devpts/line_discipline.go +++ b/pkg/sentry/fsimpl/devpts/line_discipline.go @@ -112,7 +112,7 @@ type lineDiscipline struct { // replicaWaiter is used to wait on the replica end of the TTY. replicaWaiter waiter.Queue - // terminal is the terminal linked to this lineDiscipline + // terminal is the terminal linked to this lineDiscipline. terminal *Terminal } @@ -123,10 +123,6 @@ func newLineDiscipline(termios linux.KernelTermios) *lineDiscipline { return &ld } -func (l *lineDiscipline) SetTerminal(tm *Terminal) { - l.terminal = tm -} - // getTermios gets the linux.Termios for the tty. func (l *lineDiscipline) getTermios(task *kernel.Task, args arch.SyscallArguments) (uintptr, error) { l.termiosMu.RLock() diff --git a/pkg/sentry/fsimpl/devpts/terminal.go b/pkg/sentry/fsimpl/devpts/terminal.go index ed03ffda0..a3068f8a4 100644 --- a/pkg/sentry/fsimpl/devpts/terminal.go +++ b/pkg/sentry/fsimpl/devpts/terminal.go @@ -54,7 +54,8 @@ func newTerminal(n uint32) *Terminal { replicaKTTY: &kernel.TTY{Index: n}, } - t.ld.SetTerminal(&t) + t.ld.terminal = &t + return &t } @@ -111,9 +112,10 @@ func (tm *Terminal) setForegroundProcessGroup(ctx context.Context, args arch.Sys return 0, err } - tm.fgProcessGroup = task.ThreadGroup().ProcessGroup() - ret, err := task.ThreadGroup().SetForegroundProcessGroup(tm.tty(isMaster), kernel.ProcessGroupID(pgid)) + if err == nil { + tm.fgProcessGroup = task.PIDNamespace().ProcessGroupWithID(kernel.ProcessGroupID(pgid)) + } return uintptr(ret), err }