func (d *driver) waitForStart(c *execdriver.Command, waitLock chan struct{}) (int, error) {
	var (
		err    error
		output []byte
	)
	// We wait for the container to be fully running.
	// Timeout after 5 seconds. In case of broken pipe, just retry.
	// Note: The container can run and finish correctly before
	// the end of this loop
	for now := time.Now(); time.Since(now) < 5*time.Second; {
		select {
		case <-waitLock:
			// If the process dies while waiting for it, just return
			return -1, nil
		default:
		}

		output, err = d.getInfo(c.ID)
		if err == nil {
			info, err := parseLxcInfo(string(output))
			if err != nil {
				return -1, err
			}
			if info.Running {
				return info.Pid, nil
			}
		}
		time.Sleep(50 * time.Millisecond)
	}
	return -1, execdriver.ErrNotRunning
}
// wait for the process to start and return the pid for the process
wait for the process to start and return the pid for the process
// wait for the process to start and return the pid for the process
func (d *driver) waitForStart(c *execdriver.Command, waitLock chan struct{}) (int, error) {
	var (
		err    error
		output []byte
	)
	for now := time.Now(); time.Since(now) < 5*time.Second; {
		select {
		case <-waitLock:
			return -1, nil
		default:
		}
		output, err = d.getInfo(c.ID)
		if err == nil {
			info, err := parseLxcInfo(string(output))
			if err != nil {
				return -1, err
			}
			if info.Running {
				return info.Pid, nil
			}
		}
		time.Sleep(50 * time.Millisecond)
	}
	return -1, execdriver.ErrNotRunning
}
func ( d * driver ) waitForStart ( c * execdriver . Command , waitLock chan struct { } ) ( int , error ) { var ( err error output [ ] byte ) for now := time . Now ( ) ; time . Since ( now ) < 5 * time . Second ; { select { case <- waitLock : return - 1 , nil default : } output , err = d . getInfo ( c . ID ) if err == nil { info , err := parseLxcInfo ( string ( output ) ) if err != nil { return - 1 , err } if info . Running { return info . Pid , nil } } time . Sleep ( 50 * time . Millisecond ) } return - 1 , execdriver . ErrNotRunning }
wait for the process to start and return the pid for the process
wait for the process to start and return the pid for the process
// We wait for the container to be fully running. // Timeout after 5 seconds. In case of broken pipe, just retry. // Note: The container can run and finish correctly before // the end of this loop // If the process dies while waiting for it, just return