$NetBSD$

--- sendlib.c.orig	Fri May 31 09:59:39 2002
+++ sendlib.c
@@ -1803,6 +1803,7 @@ send_msg (const char *path, char **args,
      */
     setsid ();
   
+#if !defined(__BROKEN_INTERIX_FORK)
     /* next we close all open files */
 #if defined(OPEN_MAX)
     for (fd = 0; fd < OPEN_MAX; fd++)
@@ -1815,9 +1816,27 @@ send_msg (const char *path, char **args,
     close (1);
     close (2);
 #endif
+#endif
 
     /* now the second fork() */
-    if ((pid = fork ()) == 0)
+    pid = fork ();
+
+#if defined(__BROKEN_INTERIX_FORK)
+    /* next we close all open files */
+#if defined(OPEN_MAX)
+    for (fd = 0; fd < OPEN_MAX; fd++)
+      close (fd);
+#elif defined(_POSIX_OPEN_MAX)
+    for (fd = 0; fd < _POSIX_OPEN_MAX; fd++)
+      close (fd);
+#else
+    close (0);
+    close (1);
+    close (2);
+#endif
+#endif
+
+    if (pid == 0)
     {
       /* "msg" will be opened as stdin */
       if (open (msg, O_RDONLY, 0) < 0)
