summary refs log tree commit diff
path: root/pkgs/os-specific/linux/iputils/open-max.patch
blob: 26bb95bd9d88d59961b340881b7a94dafa534549 (plain) (blame)
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
--- iputils-s20070202/rdisc.c.open-max	2007-08-07 11:34:03.000000000 +0200
+++ iputils-s20070202/rdisc.c	2007-08-07 11:41:30.000000000 +0200
@@ -240,14 +240,25 @@
 {
 	int t;
 	pid_t pid;
-	
+	long open_max;
+
 	if (trace)
 		return;
 
+	if ((open_max = sysconf(_SC_OPEN_MAX)) == -1) {
+		if (errno == 0) {
+			(void) fprintf(stderr, "OPEN_MAX is not supported\n");
+		}
+		else {
+			(void) fprintf(stderr, "sysconf() error\n");
+		}
+		exit(1);
+	}
+
 	if ((pid=fork()) != 0)
 		exit(0);
 
-	for (t = 0; t < OPEN_MAX; t++)
+	for (t = 0; t < open_max; t++)
 		if (t != s)
 			close(t);