Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(454)

Issue 13329043: code review 13329043: os/exec: return idempotent Closer from StdinPipe (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 8 months ago by adg
Modified:
11 years, 8 months ago
Reviewers:
r, dsymonds, bradfitz
CC:
golang-dev, r, remyoudompheng, bradfitz, dsymonds
Visibility:
Public.

Description

os/exec: return idempotent Closer from StdinPipe Before this fix, it was always an error to use the Close method on the io.WriteCloser obtained from Cmd.StdinPipe, as it would race with the Close performed by Cmd.Wait. Fixes issue 6270.

Patch Set 1 #

Patch Set 2 : diff -r 21a81bde7dc9 https://code.google.com/p/go #

Patch Set 3 : diff -r 21a81bde7dc9 https://code.google.com/p/go #

Total comments: 5

Patch Set 4 : diff -r 21a81bde7dc9 https://code.google.com/p/go #

Total comments: 6

Patch Set 5 : diff -r 4f4edc2ddd93 https://code.google.com/p/go #

Patch Set 6 : diff -r 318540e7857f https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -2 lines) Patch
M src/pkg/os/exec/exec.go View 1 2 3 4 3 chunks +20 lines, -2 lines 0 comments Download
M src/pkg/os/exec/exec_test.go View 1 2 3 4 5 2 chunks +39 lines, -0 lines 0 comments Download

Messages

Total messages: 24
adg
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go
11 years, 8 months ago (2013-08-28 05:40:43 UTC) #1
adg
Confirmed that the new test triggers a race condition with "go test -race" before the ...
11 years, 8 months ago (2013-08-28 05:43:02 UTC) #2
r
LGTM but wait for bradfitz. https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go File src/pkg/os/exec/exec.go (right): https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go#newcode16 src/pkg/os/exec/exec.go:16: "sync" this is a ...
11 years, 8 months ago (2013-08-28 05:58:21 UTC) #3
r
Fixes issue 6270.
11 years, 8 months ago (2013-08-28 05:58:53 UTC) #4
remyoudompheng
Le 28 août 2013 07:40, <adg@golang.org> a écrit : > > Reviewers: golang-dev1, > > ...
11 years, 8 months ago (2013-08-28 06:07:41 UTC) #5
r
https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go File src/pkg/os/exec/exec.go (right): https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go#newcode387 src/pkg/os/exec/exec.go:387: }) rémy points out this means only the first ...
11 years, 8 months ago (2013-08-28 06:13:05 UTC) #6
adg
PTAL https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go File src/pkg/os/exec/exec.go (right): https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go#newcode16 src/pkg/os/exec/exec.go:16: "sync" Ack. https://codereview.appspot.com/13329043/diff/6001/src/pkg/os/exec/exec.go#newcode387 src/pkg/os/exec/exec.go:387: }) On 2013/08/28 06:13:06, ...
11 years, 8 months ago (2013-08-28 06:59:07 UTC) #7
r
LGTM but wait for badboyfitz
11 years, 8 months ago (2013-08-28 07:12:30 UTC) #8
bradfitz
https://codereview.appspot.com/13329043/diff/16001/src/pkg/os/exec/exec.go File src/pkg/os/exec/exec.go (right): https://codereview.appspot.com/13329043/diff/16001/src/pkg/os/exec/exec.go#newcode376 src/pkg/os/exec/exec.go:376: wc := &closeOnce{WriteCloser: pw} This was proposed and rejected ...
11 years, 8 months ago (2013-08-28 16:23:31 UTC) #9
r
Would it mitigate enough if we embed the *os.File? -rob
11 years, 8 months ago (2013-08-28 22:21:53 UTC) #10
adg
If *os.File were an interface, yes. Unfortunately it is not and that thwarts this approach ...
11 years, 8 months ago (2013-08-28 22:50:44 UTC) #11
bradfitz
On Wed, Aug 28, 2013 at 3:21 PM, Rob Pike <r@golang.org> wrote: > Would it ...
11 years, 8 months ago (2013-08-28 22:51:24 UTC) #12
r
Perhaps we go back to plan B then, and introduce new methods that work and ...
11 years, 8 months ago (2013-08-28 22:58:12 UTC) #13
dsymonds
The whole point of StdinPipe returning interfaces is that it *doesn't* promise that it's an ...
11 years, 8 months ago (2013-08-29 02:39:21 UTC) #14
r
All right, you've convinced me. It's an io.WriteCloser. If someone asserts that to something else, ...
11 years, 8 months ago (2013-08-29 03:13:40 UTC) #15
r
https://codereview.appspot.com/13329043/diff/16001/src/pkg/os/exec/exec.go File src/pkg/os/exec/exec.go (right): https://codereview.appspot.com/13329043/diff/16001/src/pkg/os/exec/exec.go#newcode388 src/pkg/os/exec/exec.go:388: c.close.Do(func() { a method value is an allocation too. ...
11 years, 8 months ago (2013-08-29 03:15:17 UTC) #16
bradfitz
I'm fine changing it too. But I still think it'd be prudent to embed the ...
11 years, 8 months ago (2013-08-29 03:24:00 UTC) #17
r
SGTM
11 years, 8 months ago (2013-08-29 03:45:45 UTC) #18
adg
PTAL Now with embedded *os.File. https://codereview.appspot.com/13329043/diff/16001/src/pkg/os/exec/exec.go File src/pkg/os/exec/exec.go (right): https://codereview.appspot.com/13329043/diff/16001/src/pkg/os/exec/exec.go#newcode387 src/pkg/os/exec/exec.go:387: func (c *closeOnce) Close() ...
11 years, 8 months ago (2013-08-29 04:26:47 UTC) #19
r
LGTM but again wait for the fitzoid
11 years, 8 months ago (2013-08-29 04:31:11 UTC) #20
bradfitz
Document (with issue link) and test the embedding? On Aug 28, 2013 9:26 PM, <adg@golang.org> ...
11 years, 8 months ago (2013-08-29 04:31:39 UTC) #21
dsymonds
LGTM modulo the things raised by the fitzoid.
11 years, 8 months ago (2013-08-29 04:34:14 UTC) #22
bradfitz
LGTM after test/comment addition. I'm off now. Don't wait for me to submit. On Aug ...
11 years, 8 months ago (2013-08-29 04:37:12 UTC) #23
adg
11 years, 8 months ago (2013-08-29 04:41:51 UTC) #24
*** Submitted as https://code.google.com/p/go/source/detail?r=ef345053cf89 ***

os/exec: return idempotent Closer from StdinPipe

Before this fix, it was always an error to use the Close method on the
io.WriteCloser obtained from Cmd.StdinPipe, as it would race with the
Close performed by Cmd.Wait.

Fixes issue 6270.

R=golang-dev, r, remyoudompheng, bradfitz, dsymonds
CC=golang-dev
https://codereview.appspot.com/13329043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b