aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/lang/natWin32Process.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/java/lang/natWin32Process.cc')
-rw-r--r--libjava/java/lang/natWin32Process.cc54
1 files changed, 14 insertions, 40 deletions
diff --git a/libjava/java/lang/natWin32Process.cc b/libjava/java/lang/natWin32Process.cc
index 710753e..86fd5b3 100644
--- a/libjava/java/lang/natWin32Process.cc
+++ b/libjava/java/lang/natWin32Process.cc
@@ -9,18 +9,11 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
-
-#include <stdio.h>
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include <platform.h>
// Conflicts with the definition in "java/lang/reflect/Modifier.h"
#undef STRICT
-#include <gcj/cni.h>
-#include <jvm.h>
-
#include <java/lang/ConcreteProcess.h>
#include <java/lang/IllegalThreadStateException.h>
#include <java/lang/InterruptedException.h>
@@ -111,16 +104,6 @@ java::lang::ConcreteProcess::waitFor (void)
return exitCode;
}
-static char *
-new_string (jstring string)
-{
- jsize s = _Jv_GetStringUTFLength (string);
- char *buf = (char *) _Jv_Malloc (s + 1);
- _Jv_GetStringUTFRegion (string, 0, s, buf);
- buf[s] = '\0';
- return buf;
-}
-
void
java::lang::ConcreteProcess::startProcess (jstringArray progarray,
jstringArray envp,
@@ -177,9 +160,7 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
}
// Get the working directory path, if specified.
- char *wdir = NULL;
- if (dir != NULL)
- wdir = new_string (dir->getPath ());
+ JV_TEMP_UTF_STRING (wdir, dir ? dir->getPath () : 0);
errorStream = NULL;
inputStream = NULL;
@@ -204,29 +185,25 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
sAttrs.lpSecurityDescriptor = NULL;
- char tmpBuff[64];
if (CreatePipe (&cldStdInRd, &cldStdInWr, &sAttrs, 0) == 0)
{
- sprintf (tmpBuff,
- "Error creating stdin pipe (Win32 Error Code: %lu)",
- GetLastError ());
- throw new IOException (JvNewStringLatin1 (tmpBuff));
+ DWORD dwErrorCode = GetLastError ();
+ throw new IOException (_Jv_WinStrError ("Error creating stdin pipe",
+ dwErrorCode));
}
if (CreatePipe (&cldStdOutRd, &cldStdOutWr, &sAttrs, 0) == 0)
{
- sprintf (tmpBuff,
- "Error creating stdout pipe (Win32 Error Code: %lu)",
- GetLastError ());
- throw new IOException (JvNewStringLatin1 (tmpBuff));
+ DWORD dwErrorCode = GetLastError ();
+ throw new IOException (_Jv_WinStrError ("Error creating stdout pipe",
+ dwErrorCode));
}
if (CreatePipe (&cldStdErrRd, &cldStdErrWr, &sAttrs, 0) == 0)
{
- sprintf (tmpBuff,
- "Error creating stderr pipe (Win32 Error Code: %lu)",
- GetLastError ());
- throw new IOException (JvNewStringLatin1 (tmpBuff));
+ DWORD dwErrorCode = GetLastError ();
+ throw new IOException (_Jv_WinStrError ("Error creating stderr pipe",
+ dwErrorCode));
}
outputStream = new FileOutputStream
@@ -263,10 +240,9 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
&si,
&pi) == 0)
{
- sprintf (tmpBuff,
- "Error creating child process (Win32 Error Code: %lu)",
- GetLastError ());
- throw new IOException (JvNewStringLatin1 (tmpBuff));
+ DWORD dwErrorCode = GetLastError ();
+ throw new IOException (
+ _Jv_WinStrError ("Error creating child process", dwErrorCode));
}
procHandle = (jint ) pi.hProcess;
@@ -279,8 +255,6 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray,
_Jv_Free (cmdLine);
if (env != NULL)
_Jv_Free (env);
- if (wdir != NULL)
- _Jv_Free (wdir);
}
catch (java::lang::Throwable *thrown)
{