Index: trunk/src/kern_head.c
===================================================================
--- trunk/src/kern_head.c	(revision 91)
+++ trunk/src/kern_head.c	(revision 92)
@@ -726,4 +726,6 @@
   if      (utbuf.release[0] == '3')
     which = 38;
+  else if (utbuf.release[0] == '4')
+    which = 40;
 #else
   if      (utbuf.release[0] == '4')
@@ -791,5 +793,5 @@
     printf("\n/* Kernel %s, machine %s -- use table %s */\n\n",
                  utbuf.release, utbuf.machine, "callz_fbsd5");
-  else if (which == 38)
+  else if (which == 38 || which == 40)
     printf("\n/* Kernel %s, machine %s -- use table %s */\n\n",
                  utbuf.release, utbuf.machine, "callz_obsd");
@@ -817,5 +819,5 @@
       }
   }
-  else if (which == 38) {
+  else if (which == 38 || which == 40) {
     while ((callz_obsd[i] != NULL) && (i < SYS_MAXSYSCALL))
       {
Index: trunk/src/samhain.c
===================================================================
--- trunk/src/samhain.c	(revision 91)
+++ trunk/src/samhain.c	(revision 92)
@@ -914,5 +914,5 @@
       default:
 	times = 0;
-	while (times < 120) {
+	while (times < 300) {
 	  respid = waitpid(pid, &status, WNOHANG|WUNTRACED);
 	  if ((pid_t)-1 == respid)
@@ -1122,4 +1122,9 @@
   SL_ENTER(_("main"));
 
+  /* --- Close all but first three file descriptors. ---
+   */
+  sh_unix_closeall(3, -1); /* at program start */
+
+
   if (argc >= 2 && 0 != getuid() &&
       (0 == strcmp(argv[1], _("start")) ||
@@ -1311,9 +1316,4 @@
   sh.flag.opts = S_FALSE;
   
-
-  /* close all other files
-   */
-  sh_unix_closeall(3, -1); /* after processing CL options; only stderr here */
-
 
   /* --- Get user info. ---
Index: trunk/src/sh_unix.c
===================================================================
--- trunk/src/sh_unix.c	(revision 91)
+++ trunk/src/sh_unix.c	(revision 92)
@@ -1849,7 +1849,9 @@
   if (goDaemon == 1)
     {
-      /* close all file descriptors 
+      /* Close first tree file descriptors 
        */ 
-      sh_unix_closeall (0, -1);  /* if running as daemon */
+      close (0);  /* if running as daemon */
+      close (1);  /* if running as daemon */
+      close (2);  /* if running as daemon */
 
       /* Enable full error logging
@@ -1913,5 +1915,4 @@
   else
     {
-      sh_unix_closeall(3, -1);  /* if not daemon */
       sh_error_enable_unsafe (S_TRUE);
 #if defined(HAVE_LIBPRELUDE)
