Initial commit: Uploaded everything from abs/core
[arch-rock.git] / support / gpm / gpm-openmax.patch
blobc74291f5234f972230562da9e618a1cc7b24faf2
1 The OPEN_MAX constant was removed in Linux 2.6.23
2 (commit 77293034696e3e0b6c8b8fc1f96be091104b3d2b)
3 and sysconf is the POSIX way to do it.
5 Signed-off-by: Tomas Janousek <tjanouse@redhat.com>
6 ---
7 src/prog/gpm-root.y | 4 +++-
8 src/special.c | 4 +++-
9 2 files changed, 6 insertions(+), 2 deletions(-)
11 diff --git a/src/prog/gpm-root.y b/src/prog/gpm-root.y
12 index 3a97602..b496550 100644
13 --- a/src/prog/gpm-root.y
14 +++ b/src/prog/gpm-root.y
15 @@ -526,7 +526,9 @@ int f_bgcmd(int mode, DrawItem *self, int uid)
16 open("/dev/null",O_RDONLY); /* stdin */
17 open(consolename,O_WRONLY); /* stdout */
18 dup(1); /* stderr */
19 - for (i=3;i<OPEN_MAX; i++) close(i);
20 + int open_max = sysconf(_SC_OPEN_MAX);
21 + if (open_max == -1) open_max = 1024;
22 + for (i=3;i<open_max; i++) close(i);
23 execl("/bin/sh","sh","-c",self->arg,(char *)NULL);
24 exit(1); /* shouldn't happen */
25 default: return 0;
26 diff --git a/src/special.c b/src/special.c
27 index 5bed91a..c6cd04d 100644
28 --- a/src/special.c
29 +++ b/src/special.c
30 @@ -156,6 +156,8 @@ int processSpecial(Gpm_Event *event)
31 open(GPM_NULL_DEV,O_RDONLY); /* stdin */
32 open(console.device, O_WRONLY); /* stdout */
33 dup(1); /* stderr */
34 - for (i=3;i<OPEN_MAX; i++) close(i);
35 + int open_max = sysconf(_SC_OPEN_MAX);
36 + if (open_max == -1) open_max = 1024;
37 + for (i=3;i<open_max; i++) close(i);
38 execl("/bin/sh","sh","-c",command,(char *)NULL);
39 exit(1); /* shouldn't happen */