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

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

		runningLink: &sync.Once{},

		linked: make(chan struct{}),

		exited: make(chan struct{}),

		stdin:     writer.NewFanIn(),
		stdout:    writer.NewFanOut(),
		stderr:    writer.NewFanOut(),
		signaller: signaller,
	}
}
Example #2
0
import (
	"github.com/cloudfoundry-incubator/garden-linux/process_tracker/writer"

	"errors"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("FanOut", func() {
	var fanOut writer.FanOut
	var fWriter *fakeWriter
	var testBytes []byte

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

	It("writes data to a sink", func() {
		fanOut.AddSink(fWriter)
		n, err := fanOut.Write(testBytes)

		Expect(err).ToNot(HaveOccurred())
		Expect(n).To(Equal(1))

		Expect(fWriter.writeArgument()).To(Equal(testBytes))
		Expect(fWriter.writeCalls()).To(Equal(1))