[go] os/exec: second call to Cmd.Start is always an error

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Dec 22, 2025, 1:43:11 PM (21 hours ago) Dec 22
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Damien Neil, Go LUCI, Kirill Kolyshkin, Ефим Верзаков, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
os/exec: second call to Cmd.Start is always an error

Previously it would return an error only if the first call
resulted in process creation, contra the intent of the
comment at exec.Cmd:

// A Cmd cannot be reused after calling its [Cmd.Start], [Cmd.Run],
// [Cmd.Output], or [Cmd.CombinedOutput] methods.

Also, clear the Cmd.goroutines slice in case of failure to
start a process, so that the closures can be GC'd and their
pipe fds finalized and closed.

Fixes #76746
Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
Reviewed-by: Damien Neil <dn...@google.com>
Files:
  • M src/os/exec/exec.go
  • M src/os/exec/exec_test.go
Change size: S
Delta: 2 files changed, 33 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Damien Neil
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Ic63a4dced0aa52c2d4be7d44f6dcfc84ee22282c
Gerrit-Change-Number: 728642
Gerrit-PatchSet: 5
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Damien Neil <dn...@google.com>
Gerrit-Reviewer: Kirill Kolyshkin <koly...@gmail.com>
Gerrit-CC: Ефим Верзаков <efimve...@gmail.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages