Like the subprocess.check_*() helper functions, but tailored to bang.

    ``cmd_list`` is the command to run, and its arguments as a list of strings.

    ``input_data`` is the optional data to pass to the command's stdin.

    On success, returns the output (i.e. stdout) of the remote command.

    On failure, raises BangError with the command's stderr.

def fork_exec(cmd_list, input_data=None):
    """
    Like the subprocess.check_*() helper functions, but tailored to bang.

    ``cmd_list`` is the command to run, and its arguments as a list of strings.

    ``input_data`` is the optional data to pass to the command's stdin.

    On success, returns the output (i.e. stdout) of the remote command.

    On failure, raises BangError with the command's stderr.
    """
    # log.debug('fork_exec: cmd_list = %s, input_data = ^%s^' %
    #         (cmd_list, input_data))
    p = subprocess.Popen(
            cmd_list,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            )
    out = p.communicate(input_data)
    if p.returncode != 0:
        raise bang.BangError('ret: %d, stdout: ^%s^, stderr: ^%s^' %
                (p.returncode, out[0], out[1]))
    return out[0]