aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/gpm/gpm-1.20.1/gpm-OPEN_MAX.patch
blob: 6fa86e116892a61c9386e09ef89a9fbbdb9714f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Index: gpm-1.20.1/src/prog/gpm-root.y
===================================================================
--- gpm-1.20.1.orig/src/prog/gpm-root.y
+++ gpm-1.20.1/src/prog/gpm-root.y
@@ -44,7 +44,6 @@
 #include <sys/stat.h>       /* fstat() */
 #include <sys/utsname.h>    /* uname() */
 #include <termios.h>        /* winsize */
-#include <linux/limits.h>   /* OPEN_MAX */
 #include <linux/vt.h>       /* VT_ACTIVATE */
 #include <linux/keyboard.h> /* K_SHIFT */
 #include <utmp.h>         
@@ -525,7 +524,9 @@ int f_bgcmd(int mode, DrawItem *self, in
 	            open("/dev/null",O_RDONLY); /* stdin  */
 	            open(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",self->arg,(char *)NULL);
 	            exit(1); /* shouldn't happen */
 	         default: return 0;
Index: gpm-1.20.1/src/special.c
===================================================================
--- gpm-1.20.1.orig/src/special.c
+++ gpm-1.20.1/src/special.c
@@ -25,7 +25,6 @@
 
 /* This file is compiled conditionally, see the Makefile */
 
-#include <linux/limits.h> /* for OPEN_MAX */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -155,7 +154,9 @@ int processSpecial(Gpm_Event *event)
       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 */