[lxc-devel] [lxd/master] shared/termios: Add shim for non-cgo builds

stgraber on Github lxc-bot at linuxcontainers.org
Wed Dec 5 04:44:02 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 370 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181205/bd0a225c/attachment.bin>
-------------- next part --------------
From 0f1e3f83b6d742fd860b7e867ed9d8e0027fed59 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 4 Dec 2018 23:41:41 -0500
Subject: [PATCH] shared/termios: Add shim for non-cgo builds
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #5329

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 shared/termios/termios_other.go | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 shared/termios/termios_other.go

diff --git a/shared/termios/termios_other.go b/shared/termios/termios_other.go
new file mode 100644
index 0000000000..272a627793
--- /dev/null
+++ b/shared/termios/termios_other.go
@@ -0,0 +1,32 @@
+// +build !windows,!cgo
+
+package termios
+
+import (
+	"golang.org/x/crypto/ssh/terminal"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+func IsTerminal(fd int) bool {
+	return terminal.IsTerminal(fd)
+}
+
+// GetState returns the current state of a terminal which may be useful to restore the terminal after a signal.
+func GetState(fd int) (*terminal.State, error) {
+	return terminal.GetState(fd)
+}
+
+// GetSize returns the dimensions of the given terminal.
+func GetSize(fd int) (int, int, error) {
+	return terminal.GetSize(fd)
+}
+
+// MakeRaw put the terminal connected to the given file descriptor into raw mode and returns the previous state of the terminal so that it can be restored.
+func MakeRaw(fd int) (*terminal.State, error) {
+	return terminal.MakeRaw(fd)
+}
+
+// Restore restores the terminal connected to the given file descriptor to a previous state.
+func Restore(fd int, state *terminal.State) error {
+	return terminal.Restore(fd, state)
+}


More information about the lxc-devel mailing list