Example #1
0
func NewProcess(
	id string,
	containerPath string,
	iodaemonBin string,
	runner command_runner.CommandRunner,
) *Process {
	return &Process{
		id: id,

		iodaemonBin:   iodaemonBin,
		containerPath: containerPath,
		runner:        runner,

		runningLink: &sync.Once{},

		linked: make(chan struct{}),

		exited: make(chan struct{}),

		stdin:  writer.NewFanIn(),
		stdout: writer.NewFanOut(),
		stderr: writer.NewFanOut(),
	}
}
Example #2
0
import (
	"strings"

	"github.com/cloudfoundry-incubator/guardian/rundmc/process_tracker/writer"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("FanIn", func() {

	var fanIn writer.FanIn
	var fWriter *fakeWriter
	var testBytes []byte

	BeforeEach(func() {
		fanIn = writer.NewFanIn()
		fWriter = &fakeWriter{
			nWriteReturn: 10,
		}
		testBytes = []byte{12}
	})

	It("writes data to a sink and leaves the sink open", func() {
		fanIn.AddSink(fWriter)
		n, err := fanIn.Write(testBytes)
		Expect(err).ToNot(HaveOccurred())
		Expect(n).To(Equal(10))
		Expect(fWriter.writeCalls()).To(Equal(1))
		Expect(fWriter.writeArgument()).To(Equal(testBytes))
		Expect(fWriter.closeCalls()).To(Equal(0))