protected function sendCommand($command, $payload) {
    fwrite($this->pipes[0], $command . ':' . $payload . PHP_EOL);

    $status_line = trim(fgets($this->pipes[1]));

    // An empty status line means the script has stopped responding, and has
    // presumably crashed.
    if (empty($status_line)) {
      return FALSE;
    }

    // An expected status line that matches the sent command means everything
    // went fine.
    if ($status_line == "$command OK") {
      return TRUE;
    }

    // If something's gone wrong, get any further output from the script so we
    // can see error messages.
    while ($line = fgets($this->pipes[1])) {
      dump($line);
    }

    throw new \Exception("Command $command with payload '$payload' failed.");
  }