static struct option longopts[] =
{
{ "foreground", 0, 0, 'F' },
- { "descriptors", 0, 0, 'o' },
+ { "descriptors", 1, 0, 'o' },
{ "debug", 1, 0, 'd' },
{ "help", 0, 0, 'h' },
{ "exports-file", 1, 0, 'f' },
/* Parse the command line options and arguments. */
opterr = 0;
- while ((c = getopt_long(argc, argv, "o:Fd:f:p:P:hN:V:v", longopts, NULL)) != EOF)
+ while ((c = getopt_long(argc, argv, "on:Fd:f:p:P:hN:V:v", longopts, NULL)) != EOF)
switch (c) {
case 'o':
descriptors = atoi(optarg);
/* WARNING: the following works on Linux and SysV, but not BSD! */
sigaction(SIGCHLD, &sa, NULL);
+ /* Daemons should close all extra filehandles ... *before* RPC init. */
+ if (!foreground) {
+ int fd = sysconf (_SC_OPEN_MAX);
+ while (--fd > 2)
+ (void) close(fd);
+ }
+
if (nfs_version & 0x1)
rpc_init("mountd", MOUNTPROG, MOUNTVERS,
mount_dispatch, port);