diff options
-rw-r--r-- | nslcd/nslcd.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index 83d4e95..8b36732 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -653,6 +653,14 @@ int main(int argc,char *argv[]) log_log(LOG_ERR,"daemon may already be active, cannot acquire lock (%s): %s",NSLCD_PIDFILE,strerror(errno)); exit(EXIT_FAILURE); } + /* close all file descriptors (except stdin/out/err) */ + i=sysconf(_SC_OPEN_MAX); + /* if the system does not have OPEN_MAX just close the first 32 and + hope we closed enough */ + if (i<0) + i=32; + for (;i>3;i--) + close(i); /* daemonize */ if ((!nslcd_debugging)&&(daemon(0,0)<0)) { |