FreeBSD/contrib/ntp/libntp/ntp_worker.c
/*
 * close_all_beyond()
 *
 * Close all file descriptors after the given keep_fd, which is the
 * highest fd to keep open.
 */
close_all_beyond()
Close all file descriptors after the given keep_fd, which is the
highest fd to keep open.
close_all_beyond () Close all file descriptors after the given keep_fd which is the highest fd to keep open .
void
close_all_beyond(
	int keep_fd
	)
{
# ifdef HAVE_CLOSEFROM
	closefrom(keep_fd + 1);
# elif defined(F_CLOSEM)
	if (fcntl(keep_fd + 1, F_CLOSEM, 0) == -1)
		msyslog(LOG_ERR, "F_CLOSEM(%d): %m", keep_fd + 1);
# else	
	int fd;
	int max_fd;
	max_fd = GETDTABLESIZE();
	for (fd = keep_fd + 1; fd < max_fd; fd++)
		close(fd);
# endif	
}
void close_all_beyond ( int keep_fd ) { # ifdef HAVE_CLOSEFROM closefrom ( keep_fd + 1 ) ; # elif defined ( F_CLOSEM ) if ( fcntl ( keep_fd + 1 , F_CLOSEM , 0 ) == -1 ) msyslog ( LOG_ERR , " " , keep_fd + 1 ) ; # else int fd ; int max_fd ; max_fd = GETDTABLESIZE ( ) ; for ( fd = keep_fd + 1 ; fd < max_fd ; fd ++ ) close ( fd ) ; # endif }
close_all_beyond()
 Close all file descriptors after the given keep_fd, which is the
 highest fd to keep open.
close_all_beyond () Close all file descriptors after the given keep_fd which is the highest fd to keep open .
/*
	 * From 'Writing Reliable AIX Daemons,' SG24-4946-00,
	 * by Eric Agar (saves us from doing 32767 system
	 * calls)
	 */ /* !HAVE_CLOSEFROM && !F_CLOSEM follows */ /* !HAVE_CLOSEFROM && !F_CLOSEM */