def fork_exec(args, stdin='', **kwargs):
    """
    Do a fork-exec through the subprocess.Popen abstraction in a way
    that takes a stdin and return stdout.
    """

    as_bytes = isinstance(stdin, bytes)
    source = stdin if as_bytes else stdin.encode(locale)
    p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE, **kwargs)
    stdout, stderr = p.communicate(source)
    if as_bytes:
        return stdout, stderr
    return (stdout.decode(locale), stderr.decode(locale))
def fork_exec ( args , stdin = '' , ** kwargs ) : as_bytes = isinstance ( stdin , bytes ) source = stdin if as_bytes else stdin . encode ( locale ) p = Popen ( args , stdin = PIPE , stdout = PIPE , stderr = PIPE , ** kwargs ) stdout , stderr = p . communicate ( source ) if as_bytes : return stdout , stderr return ( stdout . decode ( locale ) , stderr . decode ( locale ) )
Do a fork-exec through the subprocess.Popen abstraction in a way
    that takes a stdin and return stdout.