FreeBSD/tests/sys/file/closefrom_test.c
/*
 * Use kinfo_getfile() to fetch the list of file descriptors and figure out
 * the highest open file descriptor.
 */
Use kinfo_getfile() to fetch the list of file descriptors and figure out
the highest open file descriptor.
Use kinfo_getfile () to fetch the list of file descriptors and figure out the highest open file descriptor .
static int
highest_fd(void)
{
	struct kinfo_file *kif;
	int cnt, i, highest;
	kif = kinfo_getfile(getpid(), &cnt);
	if (kif == NULL)
		fail_err("kinfo_getfile");
	highest = INT_MIN;
	for (i = 0; i < cnt; i++)
		if (kif[i].kf_fd > highest)
			highest = kif[i].kf_fd;
	free(kif);
	return (highest);
}
static int highest_fd ( void ) { struct kinfo_file * kif ; int cnt , i , highest ; kif = kinfo_getfile ( getpid ( ) , & cnt ) ; if ( kif == NULL ) fail_err ( " " ) ; highest = INT_MIN ; for ( i = 0 ; i < cnt ; i ++ ) if ( kif [ i ] . kf_fd > highest ) highest = kif [ i ] . kf_fd ; free ( kif ) ; return ( highest ) ; }
Use kinfo_getfile() to fetch the list of file descriptors and figure out
 the highest open file descriptor.
Use kinfo_getfile () to fetch the list of file descriptors and figure out the highest open file descriptor .