aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2026-04-06 10:13:32 -0400
committerDavid Chase <drchase@google.com>2026-04-08 03:47:54 -0700
commit497ec0d4e1763ffd167577cc2ac5fdb82b99ad82 (patch)
treef4353a9e4515a5acb628334f8d4a78d6556760d9 /src
parent6797caf71af755fb0fb1c7be72664619ac79f56f (diff)
downloadgo-497ec0d4e1763ffd167577cc2ac5fdb82b99ad82.tar.xz
cmd/go/internal/tool: only forward SIGHUP, SIGINT, SIGQUIT, and SIGTERM
These are the signals that are likely to be sent to go tool by other programs. This means we won't forward SIGTSTP, SIGTTIN, SIGTTOU. Doing so was breaking expected behavior in a terminal. Fixes #76173 Change-Id: I018808e8ecf59e4e111f353968d83b856a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/763060 Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/go/internal/tool/signal.go14
-rw-r--r--src/cmd/go/internal/tool/signal_js.go14
-rw-r--r--src/cmd/go/internal/tool/signal_plan9.go14
-rw-r--r--src/cmd/go/internal/tool/tool.go2
4 files changed, 43 insertions, 1 deletions
diff --git a/src/cmd/go/internal/tool/signal.go b/src/cmd/go/internal/tool/signal.go
new file mode 100644
index 0000000000..a6525c8d68
--- /dev/null
+++ b/src/cmd/go/internal/tool/signal.go
@@ -0,0 +1,14 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build !plan9 && !js
+
+package tool
+
+import (
+ "os"
+ "syscall"
+)
+
+var signalsToForward = []os.Signal{syscall.SIGHUP, os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM}
diff --git a/src/cmd/go/internal/tool/signal_js.go b/src/cmd/go/internal/tool/signal_js.go
new file mode 100644
index 0000000000..064f88ffb2
--- /dev/null
+++ b/src/cmd/go/internal/tool/signal_js.go
@@ -0,0 +1,14 @@
+// Copyright 2026 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build js
+
+package tool
+
+import (
+ "os"
+ "syscall"
+)
+
+var signalsToForward = []os.Signal{os.Interrupt, syscall.SIGQUIT, syscall.SIGTERM}
diff --git a/src/cmd/go/internal/tool/signal_plan9.go b/src/cmd/go/internal/tool/signal_plan9.go
new file mode 100644
index 0000000000..45fa878a68
--- /dev/null
+++ b/src/cmd/go/internal/tool/signal_plan9.go
@@ -0,0 +1,14 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build plan9
+
+package tool
+
+import (
+ "os"
+ "syscall"
+)
+
+var signalsToForward = []os.Signal{syscall.SIGHUP, os.Interrupt, syscall.SIGTERM}
diff --git a/src/cmd/go/internal/tool/tool.go b/src/cmd/go/internal/tool/tool.go
index a84b2e8ccb..094c5b719b 100644
--- a/src/cmd/go/internal/tool/tool.go
+++ b/src/cmd/go/internal/tool/tool.go
@@ -403,7 +403,7 @@ func runBuiltTool(toolName string, env, cmdline []string) error {
err := toolCmd.Start()
if err == nil {
c := make(chan os.Signal, 100)
- signal.Notify(c)
+ signal.Notify(c, signalsToForward...)
go func() {
for sig := range c {
toolCmd.Process.Signal(sig)