Skip to content

Commit a1fb741

Browse files
committed
Fixed bug with ctl+c disconnecting session
1 parent b3489c4 commit a1fb741

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/connect.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"os/exec"
66
"time"
7+
"syscall"
8+
"os"
79

810
"github.com/null93/aws-knox/sdk/credentials"
911
"github.com/null93/aws-knox/sdk/picker"
@@ -165,13 +167,15 @@ var connectCmd = &cobra.Command{
165167
fmt.Sprintf(`{"Target": "%s"}`, connectInstanceId),
166168
fmt.Sprintf("https://ssm.%s.amazonaws.com", role.Region),
167169
)
168-
command.Stdin = cmd.InOrStdin()
169-
command.Stdout = cmd.OutOrStdout()
170-
command.Stderr = cmd.ErrOrStderr()
170+
command.Stdin = os.Stdin
171+
command.Stdout = os.Stdout
172+
command.Stderr = os.Stderr
173+
command.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, Foreground: true }
171174
err = command.Run()
172175
if err != nil {
173176
ExitWithError(20, "failed to run session-manager-plugin", err)
174177
}
178+
fmt.Println ("EXITED")
175179
},
176180
}
177181

0 commit comments

Comments
 (0)