291 STDHOLDER holderOut = {{INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}, OFFSET_WRITE};
292 if (initHolder(env, &handles[1], &holderOut, &si.hStdOutput)) {
293
294 /* Error */
295 STDHOLDER holderErr = {{INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}, OFFSET_WRITE};
296 BOOL success;
297 if (redirectErrorStream) {
298 si.hStdError = si.hStdOutput;
299 /* Here we set the error stream to [ProcessBuilder.NullInputStream.INSTANCE]
300 value. That is in accordance with Java Doc for the redirection case.
301 The Java file for the [ handles[2] ] will be closed in ANY case. It is not
302 a handle leak. */
303 handles[2] = JAVA_INVALID_HANDLE_VALUE;
304 success = TRUE;
305 } else {
306 success = initHolder(env, &handles[2], &holderErr, &si.hStdError);
307 }
308
309 if (success) {
310 PROCESS_INFORMATION pi;
311 DWORD processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT;
312
313 si.dwFlags = STARTF_USESTDHANDLES;
314 if (!CreateProcessW(
315 NULL, /* executable name */
316 (LPWSTR)pcmd, /* command line */
317 NULL, /* process security attribute */
318 NULL, /* thread security attribute */
319 TRUE, /* inherits system handles */
320 processFlag, /* selected based on exe type */
321 (LPVOID)penvBlock,/* environment block */
322 (LPCWSTR)pdir, /* change to the new current directory */
323 &si, /* (in) startup information */
324 &pi)) /* (out) process information */
325 {
326 win32Error(env, L"CreateProcess");
327 } else {
328 closeSafely(pi.hThread);
329 ret = (jlong)pi.hProcess;
330 }
331 }
|
291 STDHOLDER holderOut = {{INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}, OFFSET_WRITE};
292 if (initHolder(env, &handles[1], &holderOut, &si.hStdOutput)) {
293
294 /* Error */
295 STDHOLDER holderErr = {{INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE}, OFFSET_WRITE};
296 BOOL success;
297 if (redirectErrorStream) {
298 si.hStdError = si.hStdOutput;
299 /* Here we set the error stream to [ProcessBuilder.NullInputStream.INSTANCE]
300 value. That is in accordance with Java Doc for the redirection case.
301 The Java file for the [ handles[2] ] will be closed in ANY case. It is not
302 a handle leak. */
303 handles[2] = JAVA_INVALID_HANDLE_VALUE;
304 success = TRUE;
305 } else {
306 success = initHolder(env, &handles[2], &holderErr, &si.hStdError);
307 }
308
309 if (success) {
310 PROCESS_INFORMATION pi;
311 DWORD processFlag = CREATE_UNICODE_ENVIRONMENT;
312
313 /* Suppress popping-up of a console window for non-console applications */
314 if (GetConsoleWindow() == NULL)
315 processFlag |= CREATE_NO_WINDOW;
316
317 si.dwFlags = STARTF_USESTDHANDLES;
318 if (!CreateProcessW(
319 NULL, /* executable name */
320 (LPWSTR)pcmd, /* command line */
321 NULL, /* process security attribute */
322 NULL, /* thread security attribute */
323 TRUE, /* inherits system handles */
324 processFlag, /* selected based on exe type */
325 (LPVOID)penvBlock,/* environment block */
326 (LPCWSTR)pdir, /* change to the new current directory */
327 &si, /* (in) startup information */
328 &pi)) /* (out) process information */
329 {
330 win32Error(env, L"CreateProcess");
331 } else {
332 closeSafely(pi.hThread);
333 ret = (jlong)pi.hProcess;
334 }
335 }
|