Run a process in background in a `with` context. Parameters given
    to this function are passed to `subprocess.Popen`. Process is kill
    when exiting the context.

def popen(*args, **kwargs):
    """Run a process in background in a `with` context. Parameters given
    to this function are passed to `subprocess.Popen`. Process is kill
    when exiting the context.
    """
    process = subprocess.Popen(*args, **kwargs)
    try:
        yield process.pid
    finally:
        os.kill(process.pid, signal.SIGTERM)
        os.waitpid(process.pid, 0)