def write_pid(pidfile):
    """Write processID to the pidfile.

    Notice:
        It exits main program if it fails to write pidfile.

    Arguments:
        pidfile (str): pidfile to update

    """
    pid = str(os.getpid())
    try:
        with open(pidfile, mode='w') as _file:
            print("writing processID {p} to pidfile".format(p=pid))
            _file.write(pid)
    except OSError as exc:
        sys.exit("failed to write pidfile:{e}".format(e=exc))
Write processID to the pidfile.

    Notice:
        It exits main program if it fails to write pidfile.

    Arguments:
        pidfile (str): pidfile to update