src/util/fdlist.c
/**
 * fdlist_truncate() - truncate fdlist
 * @list:               fdlist to operate on
 * @n_fds:              number of FDs to retain
 *
 * This shrinks the fdlist to size @n_fds. The caller must make sure the fdlist
 * is sized greater than, or equal to, @n_fds.
 *
 * If the discarded FDs were marked as consumed, then this will close them.
 * Otherwise, they're left untouched.
 */
truncate fdlist
@list:               fdlist to operate on
@n_fds:              number of FDs to retain

This shrinks the fdlist to size @n_fds. The caller must make sure the fdlist
is sized greater than, or equal to, @n_fds.

If the discarded FDs were marked as consumed, then this will close them.
Otherwise, they're left untouched.
truncate fdlist @list : fdlist to operate on @n_fds : number of FDs to retain This shrinks the fdlist to size @n_fds . The caller must make sure the fdlist is sized greater than or equal to @n_fds . If the discarded FDs were marked as consumed then this will close them . Otherwise they ' re left untouched .
void fdlist_truncate(FDList *list, size_t n_fds) {
        size_t i, n;
        int *p;
        p = fdlist_data(list);
        n = fdlist_count(list);
        c_assert(n_fds <= n);
        if (list->consumed)
                for (i = n_fds; i < n; ++i)
                        c_close(p[i]);
        list->cmsg->cmsg_len = CMSG_LEN(n_fds * sizeof(int));
}
void fdlist_truncate ( FDList * list , size_t n_fds ) { size_t i , n ; int * p ; p = fdlist_data ( list ) ; n = fdlist_count ( list ) ; c_assert ( n_fds <= n ) ; if ( list -> consumed ) for ( i = n_fds ; i < n ; ++ i ) c_close ( p [ i ] ) ; list -> cmsg -> cmsg_len = CMSG_LEN ( n_fds * sizeof ( int ) ) ; }
fdlist_truncate() - truncate fdlist
 @list:               fdlist to operate on
 @n_fds:              number of FDs to retain
fdlist_truncate () - truncate fdlist @list : fdlist to operate on @n_fds : number of FDs to retain