commit | 9c8334848f7e757a809bd2a888ff8502461167ab | [log] [tgz] |
---|---|---|
author | Todd Wang <toddw@google.com> | Wed Jan 27 21:22:11 2016 -0800 |
committer | Todd Wang <toddw@google.com> | Wed Jan 27 21:22:11 2016 -0800 |
tree | 34765f273d605aa1d2b1dcba5dce64073ae5694c | |
parent | 1383ca38c8f35afce9ec0abdaa34b40c7e52766d [diff] |
TBR: playground: Change gosh.Cmd.StdinPipe to have unlimited-size. It's more convenient for users if StdinPipe has an unlimited size; otherwise they need to worry about deadlock. You might think we could just use our buffered pipe and be done with it, but it's pretty tricky. In particular os/exec will create its own os.Pipe and a copier goroutine if we don't pass in a *os.File for exec.Cmd.Stdin, and exec.Cmd.Wait will wait for that goroutine to finish. Note that we can't call exec.Cmd.StdinPipe; that ensures that Close is only called once, but doesn't ensure Write and Close calls are synchronous. This makes a race possible: the user may call Write on the StdinPipe, concurrently with the exit-waiter goroutine calling Close on the StdinPipe when the process exits. This race has shown up on jenkins, and is also easily reproduced (under heavy machine load) with the new test. To make this all work, we create our own os.Pipe that we set for exec.Cmd.Stdin, and also create a buffered pipe, along with our own copier goroutine. MultiPart: 3/3 Change-Id: Idfbaee7611ef51b8bf786eb2cfbb074c6a0b53f3
This repository contains the Vanadium project playground.