def write_pid_to_pidfile(pidfile_path):
open_flags = (os.O_CREAT | os.O_EXCL | os.O_WRONLY)<EOL>open_mode = <NUM_LIT><EOL>pidfile_fd = os.open(pidfile_path, open_flags, open_mode)<EOL>pidfile = os.fdopen(pidfile_fd, '<STR_LIT:w>')<EOL>pid = os.getpid()<EOL>pidfile.write("<STR_LIT>" % pid)<EOL>pidfile.close()<EOL>
Write the PID in the named PID file.

        Get the numeric process ID (“PID”) of the current process
        and write it to the named file as a line of text.