lib/daemon-windows.c
/* If a pidfile has been configured, creates it and stores the running
 * process's pid in it.  Ensures that the pidfile will be deleted when the
 * process exits. */
If a pidfile has been configured, creates it and stores the running
process's pid in it.  Ensures that the pidfile will be deleted when the
process exits.
If a pidfile has been configured creates it and stores the running process ' s pid in it . Ensures that the pidfile will be deleted when the process exits .
static void
make_pidfile(void)
{
    int error;
    error = GetFileAttributes(pidfile);
    if (error != INVALID_FILE_ATTRIBUTES) {
        error = unlink(pidfile);
        if (error) {
            VLOG_FATAL("Failed to delete existing pidfile %s (%s)", pidfile,
                       ovs_strerror(errno));
        }
    }
    filep_pidfile = fopen(pidfile, "w");
    if (filep_pidfile == NULL) {
        VLOG_FATAL("failed to open %s (%s)", pidfile, ovs_strerror(errno));
    }
    flock(filep_pidfile, LOCKFILE_EXCLUSIVE_LOCK);
    fatal_signal_add_hook(unlink_pidfile, NULL, NULL, true);
    fprintf(filep_pidfile, "%ld\n", (long int) getpid());
    if (fflush(filep_pidfile) == EOF) {
        VLOG_FATAL("Failed to write into the pidfile %s", pidfile);
    }
    flock(filep_pidfile, LOCK_SHARED);
    flock(filep_pidfile, LOCK_UNLOCK);
}
static void make_pidfile ( void ) { int error ; error = GetFileAttributes ( pidfile ) ; if ( error != INVALID_FILE_ATTRIBUTES ) { error = unlink ( pidfile ) ; if ( error ) { VLOG_FATAL ( " " , pidfile , ovs_strerror ( errno ) ) ; } } filep_pidfile = fopen ( pidfile , " " ) ; if ( filep_pidfile == NULL ) { VLOG_FATAL ( " " , pidfile , ovs_strerror ( errno ) ) ; } flock ( filep_pidfile , LOCKFILE_EXCLUSIVE_LOCK ) ; fatal_signal_add_hook ( unlink_pidfile , NULL , NULL , true ) ; fprintf ( filep_pidfile , " \n " , ( long int ) getpid ( ) ) ; if ( fflush ( filep_pidfile ) == EOF ) { VLOG_FATAL ( " " , pidfile ) ; } flock ( filep_pidfile , LOCK_SHARED ) ; flock ( filep_pidfile , LOCK_UNLOCK ) ; }
If a pidfile has been configured, creates it and stores the running
 process's pid in it.
If a pidfile has been configured creates it and stores the running process ' s pid in it .
/* pidfile exists. Try to unlink() it. */ /* This will remove the exclusive lock. The shared lock will remain */ /* Don't close the pidfile till the process exits. */