fakeContainer.AttachStub = func(processID uint32, io garden.ProcessIO) (garden.Process, error) { writing := new(sync.WaitGroup) writing.Add(1) go func() { defer writing.Done() defer GinkgoRecover() _, err := fmt.Fprintf(io.Stdout, "stdout data") Ω(err).ShouldNot(HaveOccurred()) in, err := ioutil.ReadAll(io.Stdin) Ω(err).ShouldNot(HaveOccurred()) _, err = fmt.Fprintf(io.Stdout, "mirrored %s", string(in)) Ω(err).ShouldNot(HaveOccurred()) _, err = fmt.Fprintf(io.Stderr, "stderr data") Ω(err).ShouldNot(HaveOccurred()) }() process := new(fakes.FakeProcess) process.IDReturns(42) process.WaitStub = func() (int, error) { writing.Wait() return 123, nil } return process, nil }