mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add reference to terminal in lineDiscipline
This commit is contained in:
@@ -112,9 +112,8 @@ type lineDiscipline struct {
|
||||
// replicaWaiter is used to wait on the replica end of the TTY.
|
||||
replicaWaiter waiter.Queue
|
||||
|
||||
// fgProcessGroup is the foreground process group that is currently
|
||||
// connected to this TTY.
|
||||
fgProcessGroup *kernel.ProcessGroup
|
||||
// terminal is the terminal linked to this lineDiscipline
|
||||
terminal *Terminal
|
||||
}
|
||||
|
||||
func newLineDiscipline(termios linux.KernelTermios) *lineDiscipline {
|
||||
@@ -124,8 +123,8 @@ func newLineDiscipline(termios linux.KernelTermios) *lineDiscipline {
|
||||
return &ld
|
||||
}
|
||||
|
||||
func (l *lineDiscipline) SetForegroundProcessGroup(pg *kernel.ProcessGroup) {
|
||||
l.fgProcessGroup = pg
|
||||
func (l *lineDiscipline) SetTerminal(tm *Terminal) {
|
||||
l.terminal = tm
|
||||
}
|
||||
|
||||
// getTermios gets the linux.Termios for the tty.
|
||||
@@ -402,11 +401,11 @@ func (*inputQueueTransformer) transform(l *lineDiscipline, q *queue, buf []byte)
|
||||
cBytes[0] = '\r'
|
||||
}
|
||||
case l.termios.ControlCharacters[linux.VINTR]: // ctrl-c
|
||||
l.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGINT))
|
||||
l.terminal.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGINT))
|
||||
case l.termios.ControlCharacters[linux.VSUSP]: // ctrl-z
|
||||
l.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGTSTP))
|
||||
l.terminal.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGTSTP))
|
||||
case l.termios.ControlCharacters[linux.VQUIT]: // ctrl-\
|
||||
l.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGQUIT))
|
||||
l.terminal.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGQUIT))
|
||||
}
|
||||
|
||||
// In canonical mode, we discard non-terminating characters
|
||||
|
||||
@@ -39,6 +39,10 @@ type Terminal struct {
|
||||
// replicaKTTY contains the controlling process of the replica end of this
|
||||
// terminal. This field is immutable.
|
||||
replicaKTTY *kernel.TTY
|
||||
|
||||
// fgProcessGroup is the foreground process group that is currently
|
||||
// connected to this TTY.
|
||||
fgProcessGroup *kernel.ProcessGroup
|
||||
}
|
||||
|
||||
func newTerminal(n uint32) *Terminal {
|
||||
@@ -49,6 +53,8 @@ func newTerminal(n uint32) *Terminal {
|
||||
masterKTTY: &kernel.TTY{Index: n},
|
||||
replicaKTTY: &kernel.TTY{Index: n},
|
||||
}
|
||||
|
||||
t.ld.SetTerminal(&t)
|
||||
return &t
|
||||
}
|
||||
|
||||
@@ -105,8 +111,7 @@ func (tm *Terminal) setForegroundProcessGroup(ctx context.Context, args arch.Sys
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Put the processgroup also in line discipline for further signal handling
|
||||
tm.ld.SetForegroundProcessGroup(task.ThreadGroup().ProcessGroup())
|
||||
tm.fgProcessGroup = task.ThreadGroup().ProcessGroup()
|
||||
|
||||
ret, err := task.ThreadGroup().SetForegroundProcessGroup(tm.tty(isMaster), kernel.ProcessGroupID(pgid))
|
||||
return uintptr(ret), err
|
||||
|
||||
Reference in New Issue
Block a user