This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
GC patch: close /proc/stat file descriptor
- From: Jeff Sturm <jsturm at one-point dot com>
- To: java-patches at gcc dot gnu dot org
- Cc: hans_boehm at hp dot com
- Date: Sun, 24 Mar 2002 21:56:24 -0500 (EST)
- Subject: GC patch: close /proc/stat file descriptor
The linux threads port looks at /proc/stat on startup to check for
multiprocessors, but never closes it. I can't see any reason to waste a
file descriptor on it.
Tested on i686-linux.
2002-03-24 Jeff Sturm <jsturm@one-point.com>
* linux_threads.c (GC_get_nprocs): Close file descriptor.
Index: linux_threads.c
===================================================================
RCS file: /cvs/gcc/gcc/boehm-gc/linux_threads.c,v
retrieving revision 1.18
diff -u -p -r1.18 linux_threads.c
--- linux_threads.c 2002/02/12 04:37:53 1.18
+++ linux_threads.c 2002/03/25 02:38:36
@@ -1015,6 +1015,7 @@ int GC_get_nprocs()
WARN("Couldn't read /proc/stat\n", 0);
return -1;
}
+ close(f);
for (i = 0; i < len - 100; ++i) {
if (stat_buf[i] == '\n' && stat_buf[i+1] == 'c'
&& stat_buf[i+2] == 'p' && stat_buf[i+3] == 'u') {