--- gpm-1.20.1/src/special.c.lunar	2008-03-30 16:19:40.000000000 +0000         
+++ gpm-1.20.1/src/special.c	2002-12-24 22:57:16.000000000 +0000
@@ -155,7 +155,9 @@
       open(GPM_NULL_DEV,O_RDONLY); /* stdin  */
       open(option.consolename,O_WRONLY); /* stdout */
       dup(1);                     /* stderr */
-      for (i=3;i<OPEN_MAX; i++) close(i);
+      int open_max = sysconf(_SC_OPEN_MAX); 
+      if (open_max == -1) open_max = 1024; 
+      for (i=3;i<open_max; i++) close(i);
       execl("/bin/sh","sh","-c",command,(char *)NULL);
       exit(1); /* shouldn't happen */
       
