FreeBSD/contrib/blacklist/port/pidfile.c
/* Creates a pidfile with the provided name.  The new pidfile is "registered"
 * in the global variables pidfile_path and pidfile_pid so that any further
 * call to pidfile(3) can check if we are recreating the same file or a new
 * one.
 *
 * Returns 0 on success or -1 if there is any error. */
Creates a pidfile with the provided name.  The new pidfile is "registered"
in the global variables pidfile_path and pidfile_pid so that any further
call to pidfile(3) can check if we are recreating the same file or a new
one.

Returns 0 on success or -1 if there is any error.
Creates a pidfile with the provided name . The new pidfile is " registered " in the global variables pidfile_path and pidfile_pid so that any further call to pidfile ( 3 ) can check if we are recreating the same file or a new one . Returns 0 on success or - 1 if there is any error .
static int
create_pidfile(const char* path)
{
	FILE *f;
	if (register_atexit_handler() == -1)
		return -1;
	if (cleanup_old_pidfile(path) == 0)
		return 0;
	pidfile_path = strdup(path);
	if (pidfile_path == NULL)
		return -1;
	if ((f = fopen(path, "w")) == NULL) {
		free(pidfile_path);
		pidfile_path = NULL;
		return -1;
	}
	pidfile_pid = getpid();
	(void) fprintf(f, "%d\n", pidfile_pid);
	(void) fclose(f);
	return 0;
}
static int create_pidfile ( const char * path ) { FILE * f ; if ( register_atexit_handler ( ) == -1 ) return -1 ; if ( cleanup_old_pidfile ( path ) == 0 ) return 0 ; pidfile_path = strdup ( path ) ; if ( pidfile_path == NULL ) return -1 ; if ( ( f = fopen ( path , " " ) ) == NULL ) { free ( pidfile_path ) ; pidfile_path = NULL ; return -1 ; } pidfile_pid = getpid ( ) ; ( void ) fprintf ( f , " \n " , pidfile_pid ) ; ( void ) fclose ( f ) ; return 0 ; }
Creates a pidfile with the provided name.
Creates a pidfile with the provided name .