mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Support some PTY control characters
This commit is contained in:
@@ -111,6 +111,10 @@ 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
|
||||
}
|
||||
|
||||
func newLineDiscipline(termios linux.KernelTermios) *lineDiscipline {
|
||||
@@ -120,6 +124,10 @@ func newLineDiscipline(termios linux.KernelTermios) *lineDiscipline {
|
||||
return &ld
|
||||
}
|
||||
|
||||
func (l *lineDiscipline) SetForegroundProcessGroup(pg *kernel.ProcessGroup) {
|
||||
l.fgProcessGroup = pg
|
||||
}
|
||||
|
||||
// getTermios gets the linux.Termios for the tty.
|
||||
func (l *lineDiscipline) getTermios(task *kernel.Task, args arch.SyscallArguments) (uintptr, error) {
|
||||
l.termiosMu.RLock()
|
||||
@@ -393,6 +401,10 @@ func (*inputQueueTransformer) transform(l *lineDiscipline, q *queue, buf []byte)
|
||||
if l.termios.IEnabled(linux.INLCR) {
|
||||
cBytes[0] = '\r'
|
||||
}
|
||||
case l.termios.ControlCharacters[linux.VINTR]: // ctrl-c
|
||||
l.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGINT))
|
||||
case l.termios.ControlCharacters[linux.VSUSP]: // ctrl-z
|
||||
l.fgProcessGroup.SendSignal(kernel.SignalInfoPriv(linux.SIGTSTP))
|
||||
}
|
||||
|
||||
// In canonical mode, we discard non-terminating characters
|
||||
|
||||
@@ -105,6 +105,9 @@ 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())
|
||||
|
||||
ret, err := task.ThreadGroup().SetForegroundProcessGroup(tm.tty(isMaster), kernel.ProcessGroupID(pgid))
|
||||
return uintptr(ret), err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user