diff options
author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-08-14 19:53:54 +0000 |
---|---|---|
committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-08-14 19:53:54 +0000 |
commit | 16f99f45ed03d50ea6fb80e8bd04f4980479bd8a (patch) | |
tree | 919a86c6dc505c79c1bc4f535e2034b7aa80e77a /libjava | |
parent | 035eac0d126b4b8b18e31c7b4565acf6cb4786d5 (diff) | |
download | gcc-16f99f45ed03d50ea6fb80e8bd04f4980479bd8a.tar.gz |
2002-08-14 Jesse Rosenstock <jmr@ugcs.caltech.edu>
* java/lang/natPosixProcess.cc (cleanup): Added `path' argument.
(startProcess): Allocate path for chdir in async-signal-safe way.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56330 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/lang/natPosixProcess.cc | 18 |
2 files changed, 17 insertions, 6 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index e279ce94194..24a78110cb4 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2002-08-14 Jesse Rosenstock <jmr@ugcs.caltech.edu> + + * java/lang/natPosixProcess.cc (cleanup): Added `path' argument. + (startProcess): Allocate path for chdir in async-signal-safe way. + 2002-08-13 Jesse Rosenstock <jmr@ugcs.caltech.edu> Fix for PR libgcj/7570 and PR libgcj/7578: diff --git a/libjava/java/lang/natPosixProcess.cc b/libjava/java/lang/natPosixProcess.cc index a6c049b54b1..ec3eccb221e 100644 --- a/libjava/java/lang/natPosixProcess.cc +++ b/libjava/java/lang/natPosixProcess.cc @@ -88,7 +88,7 @@ new_string (jstring string) } static void -cleanup (char **args, char **env) +cleanup (char **args, char **env, char *path) { if (args != NULL) { @@ -102,6 +102,8 @@ cleanup (char **args, char **env) _Jv_Free (env[i]); _Jv_Free (env); } + if (path != NULL) + _Jv_Free (path); } // This makes our error handling a bit simpler and it lets us avoid @@ -127,6 +129,7 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, // Initialize all locals here to make cleanup simpler. char **args = NULL; char **env = NULL; + char *path = NULL; int inp[2], outp[2], errp[2], msgp[2]; inp[0] = -1; inp[1] = -1; @@ -170,6 +173,11 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, env[envp->length] = NULL; } + // We allocate this here because we can't call malloc() after + // the fork. + if (dir != NULL) + path = new_string (dir->getPath ()); + // Create pipes for I/O. MSGP is for communicating exec() // status. if (pipe (inp) || pipe (outp) || pipe (errp) || pipe (msgp) @@ -233,11 +241,9 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, close (msgp[0]); // Change directory. - if (dir != NULL) + if (path != NULL) { - // We don't care about leaking memory here; this process - // is about to terminate one way or another. - if (chdir (new_string (dir->getPath ())) != 0) + if (chdir (path) != 0) { char c = errno; write (msgp[1], &c, 1); @@ -319,7 +325,7 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, } myclose (msgp[0]); - cleanup (args, env); + cleanup (args, env, path); if (exc != NULL) throw exc; |