[PATCH] Replace OPEN_MAX with sysconf(_SC_OPEN_MAX)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 3a97602..b496550 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 5bed91a..c6cd04d 100644
--- a/src/special.c
+++ b/src/special.c
@@ -156,7 +156,9 @@ int processSpecial(Gpm_Event *event)
       open(GPM_NULL_DEV,O_RDONLY); /* stdin  */
       open(console.device, 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


-- 
Tomas Janousek, SW Engineer, Red Hat, Inc.
_______________________________________________
gpm mailing list
gpm@xxxxxxxxxxxxxx
http://lists.linux.it/listinfo/gpm

[Index of Archives]     [Kernel Development]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Gimp]     [Yosemite News]