Browse Source

close sdtin stream on EOF to propagate exec process' stdin

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 4 years ago
parent
commit
bee156fb97
1 changed files with 3 additions and 1 deletions
  1. 3 1
      pkg/compose/exec.go

+ 3 - 1
pkg/compose/exec.go

@@ -72,7 +72,7 @@ func (s *composeService) Exec(ctx context.Context, project *types.Project, opts
 	if err != nil {
 		return 0, err
 	}
-	defer resp.Close()
+	defer resp.Close() //nolint:errcheck
 
 	if opts.Tty {
 		s.monitorTTySize(ctx, exec.ID, s.apiClient.ContainerExecResize)
@@ -118,11 +118,13 @@ func (s *composeService) interactiveExec(ctx context.Context, opts api.RunOption
 			_, err := stdcopy.StdCopy(opts.Stdout, opts.Stderr, stdout)
 			outputDone <- err
 		}
+		defer stdout.Close() //nolint:errcheck
 	}()
 
 	go func() {
 		_, err := io.Copy(stdin, r)
 		inputDone <- err
+		defer stdin.Close() //nolint:errcheck
 	}()
 
 	for {