[gpm] [PATCH] Replace OPEN_MAX with sysconf(_SC_OPEN_MAX)

Tomas Janousek tjanouse@redhat.com
Thu Feb 14 15:37:23 CET 2008


Ping.

On Wed, Jul 25, 2007 at 11:42:26AM +0200, Tomas Janousek wrote:
> The OPEN_MAX constant was removed in Linux 2.6.23
> (commit 77293034696e3e0b6c8b8fc1f96be091104b3d2b)
> and sysconf is the POSIX way to do it.

-- 
Tomas Janousek, SW Engineer, Red Hat, Inc.
-------------- next part --------------
From 8d9d39bf4733590730170644d39e11a1e754795b Mon Sep 17 00:00:00 2001
From: Tomas Janousek <tjanouse@redhat.com>
Date: Wed, 25 Jul 2007 11:38:27 +0200
Subject: [PATCH] Replace OPEN_MAX with sysconf(_SC_OPEN_MAX)

The OPEN_MAX constant was removed in Linux 2.6.23
(commit 77293034696e3e0b6c8b8fc1f96be091104b3d2b)
and sysconf is the POSIX way to do it.

Signed-off-by: Tomas Janousek <tjanouse@redhat.com>
---
 src/prog/gpm-root.y |    4 +++-
 src/special.c       |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/prog/gpm-root.y b/src/prog/gpm-root.y
index 2be902f..7910ce6 100644
--- a/src/prog/gpm-root.y
+++ b/src/prog/gpm-root.y
@@ -526,7 +526,9 @@ int f_bgcmd(int mode, DrawItem *self, int uid)
 	            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;
diff --git a/src/special.c b/src/special.c
index 7fad664..ecb2d16 100644
--- a/src/special.c
+++ b/src/special.c
@@ -157,7 +157,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 */
       
-- 
1.5.2.2



More information about the gpm mailing list