@@ -17,60 +17,62 @@ func newPty() (Pty, error) {
17
17
vsn := windows .RtlGetVersion ()
18
18
if vsn .MajorVersion < 10 ||
19
19
vsn .BuildNumber < 17763 {
20
+ // If the CreatePseudoConsole API is not available, we fall back to a simpler
21
+ // implementation that doesn't create an actual PTY - just uses os.Pipe
20
22
return pipePty ()
21
23
}
22
24
23
25
return conpty .New (80 , 80 )
24
26
}
25
27
26
28
func pipePty () (Pty , error ) {
27
- inputR , inputW , err := os .Pipe ()
29
+ inFilePipeSide , inFileOurSide , err := os .Pipe ()
28
30
if err != nil {
29
31
return nil , err
30
32
}
31
33
32
- outputR , outputW , err := os .Pipe ()
34
+ outFileOurSide , outFilePipeSide , err := os .Pipe ()
33
35
if err != nil {
34
36
return nil , err
35
37
}
36
38
37
39
return & pipePtyVal {
38
- inputR ,
39
- inputW ,
40
- outputR ,
41
- outputW ,
40
+ inFilePipeSide ,
41
+ inFileOurSide ,
42
+ outFileOurSide ,
43
+ outFilePipeSide ,
42
44
}, nil
43
45
}
44
46
45
47
type pipePtyVal struct {
46
- inputR , inputW * os.File
47
- outputR , outputW * os.File
48
+ inFilePipeSide , inFileOurSide * os.File
49
+ outFileOurSide , outFilePipeSide * os.File
48
50
}
49
51
50
52
func (p * pipePtyVal ) InPipe () * os.File {
51
- return p .inputR
53
+ return p .inFilePipeSide
52
54
}
53
55
54
56
func (p * pipePtyVal ) OutPipe () * os.File {
55
- return p .outputW
57
+ return p .outFilePipeSide
56
58
}
57
59
58
60
func (p * pipePtyVal ) Reader () io.Reader {
59
- return p .outputR
61
+ return p .outFileOurSide
60
62
}
61
63
62
64
func (p * pipePtyVal ) WriteString (str string ) (int , error ) {
63
- return p .inputW .WriteString (str )
65
+ return p .inFileOurSide .WriteString (str )
64
66
}
65
67
66
68
func (p * pipePtyVal ) Resize (uint16 , uint16 ) error {
67
69
return nil
68
70
}
69
71
70
72
func (p * pipePtyVal ) Close () error {
71
- p .inputW .Close ()
72
- p .inputR .Close ()
73
- p .outputW .Close ()
74
- p .outputR .Close ()
73
+ p .inFileOurSide .Close ()
74
+ p .inFilePipeSide .Close ()
75
+ p .outFilePipeSide .Close ()
76
+ p .outFileOurSide .Close ()
75
77
return nil
76
78
}
0 commit comments