commit | 3a0910e0b8ffb006a483b3a38777f997b978ff88 | [log] [tgz] |
---|---|---|
author | Todd Wang <toddw@google.com> | Wed Jan 27 23:57:55 2016 -0800 |
committer | Todd Wang <toddw@google.com> | Wed Jan 27 23:57:55 2016 -0800 |
tree | 9cf3243b069592bdc660044e69cbe0f81f1be64b | |
parent | fdeb7e219b329932d8d1c020486a1717fce52df4 [diff] |
TBR lib: 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: 1/3 Change-Id: I3a7ed86164d1c4427ba55a88dac559f34fdd23b5
This repository contains general purpose libraries used by the Vanadium project. TEST