@@ -4,6 +4,7 @@ import (
9 "path/filepath"
10 "path/filepath"
@@ -17,7 +18,7 @@ import (
18type PersistentShell struct {
19type PersistentShell struct {
19 cmd *exec.Cmd
20 cmd *exec.Cmd
20− stdin *os.File
21+ stdin io.WriteCloser
21 isAlive bool
22 isAlive bool
22 cwd string
23 cwd string
23 mu sync.Mutex
24 mu sync.Mutex
@@ -39,22 +40,15 @@ type commandResult struct {
43− shellInstance *PersistentShell
43+var shellInstance *PersistentShell
44− shellInstanceOnce sync.Once
47func GetPersistentShell(workingDir string) *PersistentShell {
45func GetPersistentShell(workingDir string) *PersistentShell {
48− shellInstanceOnce.Do(func() {
49− shellInstance = newPersistentShell(workingDir)
52 if shellInstance == nil {
46 if shellInstance == nil {
53 shellInstance = newPersistentShell(workingDir)
47 shellInstance = newPersistentShell(workingDir)
54− } else if !shellInstance.isAlive {
49+ if !shellInstance.isAlive {
55 shellInstance = newPersistentShell(shellInstance.cwd)
50 shellInstance = newPersistentShell(shellInstance.cwd)
58 return shellInstance
52 return shellInstance
@@ -100,7 +94,7 @@ func newPersistentShell(cwd string) *PersistentShell {
101 shell := &PersistentShell{
95 shell := &PersistentShell{
102 cmd: cmd,
96 cmd: cmd,
103− stdin: stdinPipe.(*os.File),
97+ stdin: stdinPipe,
104 isAlive: true,
98 isAlive: true,
105 cwd: cwd,
99 cwd: cwd,
106 commandQueue: make(chan *commandExecution, 10),
100 commandQueue: make(chan *commandExecution, 10),