diff options
author | Nicolas Lacasse <nlacasse@google.com> | 2019-12-06 14:32:53 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-12-06 14:34:13 -0800 |
commit | 663fe840f79ac3d8e2ce1a1f1409d84cf2a9d37e (patch) | |
tree | d41038a004184463b584cc01ef8d8123a7b19bdf /pkg/sentry/kernel | |
parent | ea7a100202f01601fba613a76f106a9a45c817c8 (diff) |
Implement TTY field in control.Processes().
Threadgroups already know their TTY (if they have one), which now contains the
TTY Index, and is returned in the Processes() call.
PiperOrigin-RevId: 284263850
Diffstat (limited to 'pkg/sentry/kernel')
-rw-r--r-- | pkg/sentry/kernel/tty.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/sentry/kernel/tty.go b/pkg/sentry/kernel/tty.go index 34f84487a..048de26dc 100644 --- a/pkg/sentry/kernel/tty.go +++ b/pkg/sentry/kernel/tty.go @@ -21,8 +21,19 @@ import "sync" // // +stateify savable type TTY struct { + // Index is the terminal index. It is immutable. + Index uint32 + mu sync.Mutex `state:"nosave"` // tg is protected by mu. tg *ThreadGroup } + +// TTY returns the thread group's controlling terminal. If nil, there is no +// controlling terminal. +func (tg *ThreadGroup) TTY() *TTY { + tg.signalHandlers.mu.Lock() + defer tg.signalHandlers.mu.Unlock() + return tg.tty +} |