def write_pid_to_pidfile(pidfile_path):
 open_flags = ((os.O_CREAT | os.O_EXCL) | os.O_WRONLY)
 open_mode = 420
 pidfile_fd = os.open(pidfile_path, open_flags, open_mode)
 pidfile = os.fdopen(pidfile_fd, 'w')
 pid = os.getpid()
 pidfile.write(('%s\n' % pid))
 pidfile.close()

def write_pid_to_pidfile ( pidfile_path ) : open_flags = ( ( os . O_CREAT | os . O_EXCL ) | os . O_WRONLY ) open_mode = 420 pidfile_fd = os . open ( pidfile_path , open_flags , open_mode ) pidfile = os . fdopen ( pidfile_fd , 'w' ) pid = os . getpid ( ) pidfile . write ( ( '%s\n' % pid ) ) pidfile . close ( )
write the pid in the named pid file .