/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "lint.h"
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <limits.h>
#include <errno.h>
#include <alloca.h>
#include <sys/resource.h>
/* Initial size of the open file descriptor array */
/*
* Iterate over all open file descriptors, calling 'func' on each one.
* Terminate the iteration when 'func' returns non-zero or when all
* open file descriptors have been processed. Return the value of
* the last non-zero return from 'func' or zero.
*/
int
{
int rv = 0;
int *fds;
int nfds;
int i;
nfds = 0;
/*
* Collect all of the open file descriptors and close
* the directory before calling 'func' on any of them.
*/
/* skip '.', '..' and the opendir() fd */
continue;
fds_sz *= 2;
}
}
} else {
/*
* We could not open the /proc file descriptor directory.
* We have to do it the hard way.
*/
for (i = 0; i < max_fds; i++) {
continue;
fds_sz *= 2;
}
}
}
/*
* Restore the original value of errno so that
* the caller sees only the value of errno set
* by the callback function.
*/
/*
* Perform the callbacks on all of the open files.
*/
for (i = 0; i < nfds; i++)
break;
return (rv);
}
/*
* Call-back function for closefrom(), below.
*/
static int
{
return (0);
}
/*
* Close all open file descriptors greater than or equal to lowfd.
*/
void
{
/*
* Close lowfd right away as a hedge against failing
* to open the /proc file descriptor directory due
* all file descriptors being currently used up.
*/
}