public function execute($cmd, &$captureOutput = null)
    {
        $isInteractive = $this->container->get('INTERACTIVE');
        $process = $this->createProcess($isInteractive);

        if ($isInteractive) {
            $process->setCommandLine(sprintf('/bin/bash -c \'%s\'', $cmd));
        } else {
            $process->setInput($cmd);
        }

        if (null !== $captureOutput && false === $isInteractive) {
            $process->run(function ($type, $data) use(&$captureOutput) {
                $captureOutput .= $data;
            });
        } else {
            $process->run(array($this, 'processCallback'));
        }

        $ret = $process->getExitCode();

        if ($ret != 0) {
            if ((int)$ret == Container::ABORT_EXIT_CODE) {
                throw new ExecutionAbortedException("Command '$cmd' was aborted");
            } else {
                throw new \UnexpectedValueException("Command '$cmd' failed with exit code {$ret}");
            }
        }
        return $ret;
    }