|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
36 | 36 | * @requires !vm.musl
|
37 | 37 | * @requires vm.flagless
|
38 | 38 | * @library /test/lib
|
39 |
| - * @run main/othervm/native/timeout=300 -Djava.security.manager=allow Basic |
40 |
| - * @run main/othervm/native/timeout=300 -Djava.security.manager=allow -Djdk.lang.Process.launchMechanism=fork Basic |
| 39 | + * @run main/othervm/native/timeout=360 -Djava.security.manager=allow Basic |
| 40 | + * @run main/othervm/native/timeout=360 -Djava.security.manager=allow -Djdk.lang.Process.launchMechanism=fork Basic |
41 | 41 | * @author Martin Buchholz
|
42 | 42 | */
|
43 | 43 |
|
@@ -209,7 +209,7 @@ private static void compareLinesIgnoreCase(String lines1, String lines2) {
|
209 | 209 |
|
210 | 210 | private static final Runtime runtime = Runtime.getRuntime();
|
211 | 211 |
|
212 |
| - private static final String[] winEnvCommand = {"cmd.exe", "/c", "set"}; |
| 212 | + private static final String[] winEnvCommand = {"cmd.exe", "/d", "/c", "set"}; |
213 | 213 |
|
214 | 214 | private static String winEnvFilter(String env) {
|
215 | 215 | return env.replaceAll("\r", "")
|
@@ -1914,7 +1914,9 @@ public void doIt(Map<String,String> environ) {
|
1914 | 1914 | // Test Runtime.exec(...envp...) with envstrings without any `='
|
1915 | 1915 | //----------------------------------------------------------------
|
1916 | 1916 | try {
|
1917 |
| - String[] cmdp = {"echo"}; |
| 1917 | + // In Windows CMD (`cmd.exe`), `echo/` outputs a newline (i.e., an empty line). |
| 1918 | + // Wrapping it with `cmd.exe /c` ensures compatibility in both native Windows and Cygwin environments. |
| 1919 | + String[] cmdp = Windows.is() ? new String[]{"cmd.exe", "/c", "echo/"} : new String[]{"echo"}; |
1918 | 1920 | String[] envp = {"Hello", "World"}; // Yuck!
|
1919 | 1921 | Process p = Runtime.getRuntime().exec(cmdp, envp);
|
1920 | 1922 | equal(commandOutput(p), "\n");
|
|
0 commit comments