mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Do not allow to close /dev/stdin
This commit is contained in:
parent
a26fc9169c
commit
d59c91a461
@ -3,6 +3,7 @@ package manager
|
||||
import (
|
||||
"fmt"
|
||||
api "github.com/fsouza/go-dockerclient"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -18,6 +19,15 @@ func NewDocker(client *api.Client, id string) *Docker {
|
||||
}
|
||||
}
|
||||
|
||||
// Do not allow to close reader (i.e. /dev/stdin which docker client tries to close after command execution)
|
||||
type noClosableReader struct {
|
||||
wrappedReader io.Reader
|
||||
}
|
||||
|
||||
func (w *noClosableReader) Read(p []byte) (n int, err error) {
|
||||
return w.wrappedReader.Read(p)
|
||||
}
|
||||
|
||||
func (dc *Docker) Exec(cmd []string) error {
|
||||
execCmd, err := dc.client.CreateExec(api.CreateExecOptions{
|
||||
AttachStdin: true,
|
||||
@ -33,7 +43,7 @@ func (dc *Docker) Exec(cmd []string) error {
|
||||
}
|
||||
|
||||
return dc.client.StartExec(execCmd.ID, api.StartExecOptions{
|
||||
InputStream: os.Stdin,
|
||||
InputStream: &noClosableReader{os.Stdin},
|
||||
OutputStream: os.Stdout,
|
||||
ErrorStream: os.Stderr,
|
||||
RawTerminal: true,
|
||||
|
Loading…
Reference in New Issue
Block a user