Skip to content

Commit adfddd2

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 adfddd2

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,13 @@ func (m *master) Fd() uintptr {
154154
return m.in
155155
}
156156

157+
// on windows, console can only be made from os.Std{in,out,err}, hence there
158+
// isnt a single name here we can use. Return a dummy "console" value in this
159+
// case should be sufficient.
160+
func (m *master) Name() string {
161+
return "console"
162+
}
163+
157164
// makeInputRaw puts the terminal (Windows Console) connected to the given
158165
// file descriptor into raw mode
159166
func makeInputRaw(fd uintptr, mode uint32) error {

0 commit comments

Comments
 (0)