func (c *Cmd) StartWithTimeout(to time.Duration, exp *regexp.Regexp) error {
	c.startInNewGroup()

	var err error
	var opipe io.Reader
	if c.Stdout != nil {
		var w io.Writer
		opipe, w = io.Pipe()

		c.Stdout = io.MultiWriter(w, c.Stdout)
	} else {
		opipe, err = c.StdoutPipe()
		if err != nil {
			return err
		}
	}

	var epipe io.Reader
	if c.Stderr != nil {
		var w io.Writer
		epipe, w = io.Pipe()

		c.Stderr = io.MultiWriter(w, c.Stderr)
	} else {
		epipe, err = c.StderrPipe()
		if err != nil {
			return err
		}
	}

	c.Start()

	return iowait.WaitForRegexp(io.MultiReader(epipe, opipe), exp, to)
}
//Works like start but waits a given amount of time
//for a line from stdout that matches
//the provided regexp, if the command has an stdout or
//sterr that is not nill, it will replace the stdout with
//a io.Multiwriter that also pipes output to the stream
//that is scanned for the regex
Works like start but waits a given amount of time
for a line from stdout that matches
the provided regexp, if the command has an stdout or
sterr that is not nill, it will replace the stdout with
a io.Multiwriter that also pipes output to the stream
that is scanned for the regex
// Works like start but waits a given amount of time // for a line from stdout that matches // the provided regexp if the command has an stdout or // sterr that is not nill it will replace the stdout with // a io . Multiwriter that also pipes output to the stream // that is scanned for the regex
func (c *Cmd) StartWithTimeout(to time.Duration, exp *regexp.Regexp) error {
	c.startInNewGroup()
	var err error
	var opipe io.Reader
	if c.Stdout != nil {
		var w io.Writer
		opipe, w = io.Pipe()
		c.Stdout = io.MultiWriter(w, c.Stdout)
	} else {
		opipe, err = c.StdoutPipe()
		if err != nil {
			return err
		}
	}
	var epipe io.Reader
	if c.Stderr != nil {
		var w io.Writer
		epipe, w = io.Pipe()
		c.Stderr = io.MultiWriter(w, c.Stderr)
	} else {
		epipe, err = c.StderrPipe()
		if err != nil {
			return err
		}
	}
	c.Start()
	return iowait.WaitForRegexp(io.MultiReader(epipe, opipe), exp, to)
}
func ( c * Cmd ) StartWithTimeout ( to time . Duration , exp * regexp . Regexp ) error { c . startInNewGroup ( ) var err error var opipe io . Reader if c . Stdout != nil { var w io . Writer opipe , w = io . Pipe ( ) c . Stdout = io . MultiWriter ( w , c . Stdout ) } else { opipe , err = c . StdoutPipe ( ) if err != nil { return err } } var epipe io . Reader if c . Stderr != nil { var w io . Writer epipe , w = io . Pipe ( ) c . Stderr = io . MultiWriter ( w , c . Stderr ) } else { epipe , err = c . StderrPipe ( ) if err != nil { return err } } c . Start ( ) return iowait . WaitForRegexp ( io . MultiReader ( epipe , opipe ) , exp , to ) }
Works like start but waits a given amount of time
for a line from stdout that matches
the provided regexp, if the command has an stdout or
sterr that is not nill, it will replace the stdout with
a io.Multiwriter that also pipes output to the stream
that is scanned for the regex
Works like start but waits a given amount of time for a line from stdout that matches the provided regexp if the command has an stdout or sterr that is not nill it will replace the stdout with a io . Multiwriter that also pipes output to the stream that is scanned for the regex