(void)fprintf(f, "%d\n", getpid());
(void)fprintf(f, "%d\n", (int) getpid());
lock_host_file(lockdir)	char *lockdir;{	char *dd, *lpath;	int i, fd; 	FILE *f;	dd = strdup(inet_ntoa(remoteaddr));	if (dd == NULL) {		syslog(LOG_ERR, "Malloc failed in lock_host_file()");		return(-1);	}	i = strlen(lockdir) + strlen(dd) + 2; /* NUL and maybe a / */	lpath = (char *)malloc(i);	if (lpath == NULL) {		syslog(LOG_ERR, "Malloc failed in lock_host_file()");		free(dd);		return(-1);	}	(void) strlcpy(lpath, lockdir, i);	if (lpath[strlen(lpath) - 1] != '/') {		lpath[strlen(lpath)] = '/'; 		lpath[strlen(lpath) + 1] = '\0';	}	if (strlcat(lpath, dd, i) >= i) {		syslog(LOG_CRIT, "Buffer overrun in lock_host_file(). SHOULD NOT HAPPEN!");		abort();	}	free(dd);	if ((fd = open(lpath, O_CREAT | O_WRONLY, 0600)) < 0) {		syslog(LOG_ERR, "Couldn't open/create lock file %s (%m)", lpath);		free(lpath);		return(-1);	}#ifdef USE_LOCKF	if (lockf(fd, F_TLOCK, 0) != 0) #else	if (flock(fd, LOCK_EX | LOCK_NB ) != 0)#endif	{		syslog(LOG_DEBUG, "Can't get lock on %s.", lpath);		free(lpath);		close(fd);		return(-1);	}	if (ftruncate(fd, 0) < 0) {		syslog(LOG_ERR,		    "Couldn't ftruncate fd %d for lock file %s (%m)",		    fd, lpath);		free(lpath);		close(fd);		return(-1);	}	f = fdopen(fd, "w");	if (f == NULL) {		syslog(LOG_ERR, "Couldn't fopen fd %d for lock file %s (%m)",		    fd, lpath);		free(lpath);		close(fd);		return(-1);	}	(void)fprintf(f, "%d\n", getpid());	fflush(f);	free(lpath);	return(fd);}