This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
PATCH: waitpid in natPosixProcess.cc
- From: Casey Marshall <csm at gnu dot org>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 20 Apr 2004 16:43:09 -0700
- Subject: PATCH: waitpid in natPosixProcess.cc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Attached is a simple patch that invokes waitpid if either the process
is destroy()ed or the C call to exec() fails.
This prevents Runtime.exec from spawning zombie processes if the given
command cannot be found, or if the process is killed. I wasn't sure if
it was appropriate to call waitFor instead, but (AFAIK) calling
waitpid in these two spots is safe.
- --
Casey Marshall || csm@gnu.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/>
iD8DBQFAhbVegAuWMgRGsWsRAqMgAJwKz3hlZCEWxi+3YYjl/6Xpv941bwCeOq3G
dCSvFPKz06RDpr43ZOTz2NQ=
=4Ojo
-----END PGP SIGNATURE-----
Index: libjava/java/lang/natPosixProcess.cc
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/lang/natPosixProcess.cc,v
retrieving revision 1.15.6.1
diff -u -r1.15.6.1 natPosixProcess.cc
--- libjava/java/lang/natPosixProcess.cc 4 Feb 2004 00:04:20 -0000 1.15.6.1
+++ libjava/java/lang/natPosixProcess.cc 20 Apr 2004 23:26:21 -0000
@@ -46,6 +46,7 @@
{
// Really kill it.
kill ((pid_t) pid, SIGKILL);
+ waitpid ((pid_t) pid, NULL, 0);
}
}
@@ -320,6 +321,8 @@
myclose (inp[1]);
myclose (errp[1]);
myclose (msgp[1]);
+
+ waitpid ((pid_t) pid, NULL, 0);
exc = thrown;
}