Skip to content

Commit 304e794

Browse files
committed
console: add Name function
when sending the console over i.e. (unix.Sendfd in runc), we also use name as auxiliary data in the payload. This exposes `Name()` function. I think this should be enough, maybe a bit leaner than exposing `File` For windows, name is an empty string. Not sure if this is correct but i dont know what are other options. Signed-off-by: Daniel Dao <[email protected]>
1 parent dc4ce80 commit 304e794

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

console.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type Console interface {
2828
Size() (WinSize, error)
2929
// Fd returns the console's file descriptor
3030
Fd() uintptr
31+
// Name returns the console's file name
32+
Name() string
3133
}
3234

3335
// WinSize specifies the window size of the console

console_unix.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func (m *master) Fd() uintptr {
118118
return m.f.Fd()
119119
}
120120

121+
func (m *master) Name() string {
122+
return m.f.Name()
123+
}
124+
121125
// checkConsole checks if the provided file is a console
122126
func checkConsole(f *os.File) error {
123127
var termios unix.Termios

console_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ func (m *master) Fd() uintptr {
154154
return m.in
155155
}
156156

157+
func (m *master) Name() string {
158+
return ""
159+
}
160+
157161
// makeInputRaw puts the terminal (Windows Console) connected to the given
158162
// file descriptor into raw mode
159163
func makeInputRaw(fd uintptr, mode uint32) error {

0 commit comments

Comments
 (0)