def METHOD_NAME(mountpoint):
    '''Invoke fusermount and wait for daemon to terminate.'''
    with open('/dev/null', 'wb') as devnull:
        if subprocess.call(['fuser', '-m', mountpoint], stdout=devnull, stderr=devnull) == 0:
            raise MountInUseError(mountpoint)
    ctrlfile = os.path.join(mountpoint, CTRL_NAME)
    log.debug('Flushing cache...')
    pyfuse3.setxattr(ctrlfile, 's3ql_flushcache!', b'dummy')
    # Get pid
    log.debug('Trying to get pid')
    pid = parse_literal(pyfuse3.getxattr(ctrlfile, 's3ql_pid?'), int)
    log.debug('PID is %d', pid)
    # Get command line to make race conditions less-likely
    cmdline = get_cmdline(pid)
    # Unmount
    log.debug('Unmounting...')
    if os.getuid() == 0 or platform.system() == 'Darwin':
        # MacOS X always uses umount rather than fusermount
        umount_cmd = ['umount', mountpoint]
    else:
        umount_cmd = ['fusermount', '-u', mountpoint]
    if subprocess.call(umount_cmd) != 0:
        raise UmountSubError(mountpoint)
    # Wait for daemon
    log.debug('Uploading metadata...')
    step = 0.1
    while True:
        try:
            os.kill(pid, 0)
        except OSError:
            log.debug('Kill failed, assuming daemon has quit.')
            break
        # Check that the process did not terminate and the PID
        # was reused by a different process
        cmdline2 = get_cmdline(pid)
        if cmdline2 is None:
            log.debug('Reading cmdline failed, assuming daemon has quit.')
            break
        elif cmdline2 == cmdline:
            log.debug('PID still alive and commandline unchanged.')
        else:
            log.debug('PID still alive, but cmdline changed')
            break
        # Process still exists, we wait
        log.debug('Daemon seems to be alive, waiting...')
        time.sleep(step)
        if step < 1:
            step += 0.1