Browse code

vendor: github.com/creack/pty v1.1.11

full diff: https://github.com/creack/pty/compare/v1.1.9...v1.1.11

- v1.1.11: Add arm support for OpenBSD
- v1.1.10: Fix CTTY to work with go1.15

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2020/11/03 21:38:27
Showing 6 changed files
... ...
@@ -16,7 +16,7 @@ github.com/moby/term                                7f0af18e79f2784809e9cef63d0d
16 16
 # could be either `mountinfo/vX.Y.Z` or `mount/vX.Y.Z`.
17 17
 github.com/moby/sys                                 9a75fe61baf4b9788826b48b0518abecffb79b16 # mountinfo v0.4.0
18 18
 
19
-github.com/creack/pty                               3a6a957789163cacdfe0e291617a1c8e80612c11 # v1.1.9
19
+github.com/creack/pty                               2a38352e8b4d7ab6c336eef107e42a55e72e7fbc # v1.1.11
20 20
 github.com/sirupsen/logrus                          6699a89a232f3db797f2e280639854bbc4b89725 # v1.7.0
21 21
 github.com/tchap/go-patricia                        a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
22 22
 golang.org/x/net                                    ab34263943818b32f575efc978a3d24e80b04bd7
... ...
@@ -11,6 +11,8 @@ import (
11 11
 // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
12 12
 // and c.Stderr, calls c.Start, and returns the File of the tty's
13 13
 // corresponding pty.
14
+//
15
+// Starts the process in a new session and sets the controlling terminal.
14 16
 func Start(c *exec.Cmd) (pty *os.File, err error) {
15 17
 	return StartWithSize(c, nil)
16 18
 }
... ...
@@ -19,16 +21,35 @@ func Start(c *exec.Cmd) (pty *os.File, err error) {
19 19
 // and c.Stderr, calls c.Start, and returns the File of the tty's
20 20
 // corresponding pty.
21 21
 //
22
-// This will resize the pty to the specified size before starting the command
22
+// This will resize the pty to the specified size before starting the command.
23
+// Starts the process in a new session and sets the controlling terminal.
23 24
 func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) {
25
+	if c.SysProcAttr == nil {
26
+		c.SysProcAttr = &syscall.SysProcAttr{}
27
+	}
28
+	c.SysProcAttr.Setsid = true
29
+	c.SysProcAttr.Setctty = true
30
+	return StartWithAttrs(c, sz, c.SysProcAttr)
31
+}
32
+
33
+// StartWithAttrs assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
34
+// and c.Stderr, calls c.Start, and returns the File of the tty's
35
+// corresponding pty.
36
+//
37
+// This will resize the pty to the specified size before starting the command if a size is provided.
38
+// The `attrs` parameter overrides the one set in c.SysProcAttr.
39
+//
40
+// This should generally not be needed. Used in some edge cases where it is needed to create a pty
41
+// without a controlling terminal.
42
+func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (pty *os.File, err error) {
24 43
 	pty, tty, err := Open()
25 44
 	if err != nil {
26 45
 		return nil, err
27 46
 	}
28 47
 	defer tty.Close()
48
+
29 49
 	if sz != nil {
30
-		err = Setsize(pty, sz)
31
-		if err != nil {
50
+		if err := Setsize(pty, sz); err != nil {
32 51
 			pty.Close()
33 52
 			return nil, err
34 53
 		}
... ...
@@ -42,15 +63,11 @@ func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) {
42 42
 	if c.Stdin == nil {
43 43
 		c.Stdin = tty
44 44
 	}
45
-	if c.SysProcAttr == nil {
46
-		c.SysProcAttr = &syscall.SysProcAttr{}
47
-	}
48
-	c.SysProcAttr.Setctty = true
49
-	c.SysProcAttr.Setsid = true
50
-	c.SysProcAttr.Ctty = int(tty.Fd())
51
-	err = c.Start()
52
-	if err != nil {
53
-		pty.Close()
45
+
46
+	c.SysProcAttr = attrs
47
+
48
+	if err := c.Start(); err != nil {
49
+		_ = pty.Close()
54 50
 		return nil, err
55 51
 	}
56 52
 	return pty, err
57 53
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+// Code generated by cmd/cgo -godefs; DO NOT EDIT.
1
+// cgo -godefs types_freebsd.go
2
+
3
+package pty
4
+
5
+const (
6
+	_C_SPECNAMELEN = 0xff
7
+)
8
+
9
+type fiodgnameArg struct {
10
+	Len int32
11
+	Buf *byte
12
+}
0 13
new file mode 100644
... ...
@@ -0,0 +1,13 @@
0
+// +build openbsd
1
+// +build 386 amd64 arm arm64
2
+
3
+package pty
4
+
5
+type ptmget struct {
6
+	Cfd	int32
7
+	Sfd	int32
8
+	Cn	[16]int8
9
+	Sn	[16]int8
10
+}
11
+
12
+var ioctl_PTMGET = 0x40287401
0 13
deleted file mode 100644
... ...
@@ -1,13 +0,0 @@
1
-// Created by cgo -godefs - DO NOT EDIT
2
-// cgo -godefs types_openbsd.go
3
-
4
-package pty
5
-
6
-type ptmget struct {
7
-	Cfd	int32
8
-	Sfd	int32
9
-	Cn	[16]int8
10
-	Sn	[16]int8
11
-}
12
-
13
-var ioctl_PTMGET = 0x40287401
14 1
deleted file mode 100644
... ...
@@ -1,13 +0,0 @@
1
-// Created by cgo -godefs - DO NOT EDIT
2
-// cgo -godefs types_openbsd.go
3
-
4
-package pty
5
-
6
-type ptmget struct {
7
-	Cfd int32
8
-	Sfd int32
9
-	Cn  [16]int8
10
-	Sn  [16]int8
11
-}
12
-
13
-var ioctl_PTMGET = 0x40287401