-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: run does not relay signals to child process #40467
Comments
This issue seems to be related to my case. main.go
Running and sending interrupt, the following works as expected:
But this exits before the child process:
|
@tie That's probably related to or the same as #36976, as the Otherwise my understanding (based on trying to fix #36976) is that It'd be nice if all of these would re-exec their binaries rather than running them as children on OSs that supported it, as that'd eliminate all of these for most users. Though perhaps that's not doable if |
I'm running into the same thing. Here's a slightly reduced reproduction: child/main.go package main
import (
"fmt"
"os"
"os/signal"
)
func main() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt)
<-ch
fmt.Println("got sigint")
} main.go package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"time"
)
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}
func run() error {
cmd := exec.Command("go", "run", filepath.Join("child", "main.go"))
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {
return err
}
time.Sleep(1 * time.Second)
fmt.Println("interrupting")
if err := cmd.Process.Signal(os.Interrupt); err != nil {
return err
}
fmt.Println("interrupted")
return cmd.Wait()
} If you run the following command: $ go run scripts/test-go-run/main.go
interrupting
interrupted It will hang at |
Probably something about that needs to change in order to propagate those two signals in particular during |
It does not completely ignore it. It closes |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
The interrupt signal to be passed to the child process by
go run
, I think?What did you see instead?
The
go run
child process does not relay the interrupt signal to the child process.cc @bcmills @jayconrod @matloob
The text was updated successfully, but these errors were encountered: