Windows - Process keeps running when stdin is set
- Dominant language
- Go
- Stars
- 4.2k
- Forks
- 509
- PR merge metrics
- No merged PRs in 30d
Description
The following works fine:
```go
func runPsCmd(psCmd string) {
pthPs := `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`
cmd := exec.Command(pthPs, "-Command", psCmd)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
cmd.Stdin = os.Stdin
err := cmd.Start()
if err != nil {
panic(err)
}
err = cmd.Wait()
if err != nil {
exitError, ok := err.(*exec.ExitError)
if ok {
os.Exit(exitError.ExitCode())
} else {
panic(err)
}
}
os.Exit(0)
}
func main() {
runPsCmd("echo myTest")
}
```
However when doing the same but with:
```go
func runPsCmd(s ssh.Session, psCmd string) {
// [..]
cmd.Stderr = s
cmd.Stdout = s
cmd.Stdin = s
// [..]
}
```
`cmd.Wait()` blocks until I pressed Enter once. When I don't assign `cmd.Stdin` at all, it works as expected, but some programs may require user input. What could this by caused by? And how can this be fixed?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.