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.
From-SVN: r56330
+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:
2002-08-13 Jesse Rosenstock <jmr@ugcs.caltech.edu>
Fix for PR libgcj/7570 and PR libgcj/7578:
-cleanup (char **args, char **env)
+cleanup (char **args, char **env, char *path)
_Jv_Free (env[i]);
_Jv_Free (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
}
// This makes our error handling a bit simpler and it lets us avoid
// Initialize all locals here to make cleanup simpler.
char **args = NULL;
char **env = NULL;
// Initialize all locals here to make cleanup simpler.
char **args = NULL;
char **env = NULL;
int inp[2], outp[2], errp[2], msgp[2];
inp[0] = -1;
inp[1] = -1;
int inp[2], outp[2], errp[2], msgp[2];
inp[0] = -1;
inp[1] = -1;
env[envp->length] = NULL;
}
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)
// Create pipes for I/O. MSGP is for communicating exec()
// status.
if (pipe (inp) || pipe (outp) || pipe (errp) || pipe (msgp)
close (msgp[0]);
// Change directory.
close (msgp[0]);
// Change directory.
- // 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)
{
char c = errno;
write (msgp[1], &c, 1);
{
char c = errno;
write (msgp[1], &c, 1);
+ cleanup (args, env, path);
if (exc != NULL)
throw exc;
if (exc != NULL)
throw exc;