jdk/test/java/lang/ProcessBuilder/Basic.java
changeset 14183 26e97eede839
parent 14178 f2c729b81c6a
child 15265 507fd9b4b485
equal deleted inserted replaced
14182:3041082abb40 14183:26e97eede839
    39 import java.lang.reflect.Field;
    39 import java.lang.reflect.Field;
    40 import java.util.*;
    40 import java.util.*;
    41 import java.util.concurrent.CountDownLatch;
    41 import java.util.concurrent.CountDownLatch;
    42 import java.util.concurrent.TimeUnit;
    42 import java.util.concurrent.TimeUnit;
    43 import java.security.*;
    43 import java.security.*;
       
    44 import sun.misc.Unsafe;
    44 import java.util.regex.Pattern;
    45 import java.util.regex.Pattern;
    45 import java.util.regex.Matcher;
    46 import java.util.regex.Matcher;
    46 import static java.lang.System.getenv;
    47 import static java.lang.System.getenv;
    47 import static java.lang.System.out;
    48 import static java.lang.System.out;
    48 import static java.lang.Boolean.TRUE;
    49 import static java.lang.Boolean.TRUE;
  1958                             equal(-1, r);
  1959                             equal(-1, r);
  1959                         } catch (Throwable t) { unexpected(t); }}};
  1960                         } catch (Throwable t) { unexpected(t); }}};
  1960 
  1961 
  1961                 thread.start();
  1962                 thread.start();
  1962                 latch.await();
  1963                 latch.await();
       
  1964                 Thread.sleep(10);
  1963 
  1965 
  1964                 String os = System.getProperty("os.name");
  1966                 String os = System.getProperty("os.name");
  1965                 if (os.equalsIgnoreCase("Solaris") ||
  1967                 if (os.equalsIgnoreCase("Solaris") ||
  1966                     os.equalsIgnoreCase("SunOS"))
  1968                     os.equalsIgnoreCase("SunOS"))
  1967                 {
  1969                 {
  1981                         getDeclaredField("useCount");
  1983                         getDeclaredField("useCount");
  1982                     useCountField.setAccessible(true);
  1984                     useCountField.setAccessible(true);
  1983 
  1985 
  1984                     while (useCountField.getInt(deferred) <= 0) {
  1986                     while (useCountField.getInt(deferred) <= 0) {
  1985                         Thread.yield();
  1987                         Thread.yield();
       
  1988                     }
       
  1989                 } else if (s instanceof BufferedInputStream) {
       
  1990                     Field f = Unsafe.class.getDeclaredField("theUnsafe");
       
  1991                     f.setAccessible(true);
       
  1992                     Unsafe unsafe = (Unsafe)f.get(null);
       
  1993 
       
  1994                     while (unsafe.tryMonitorEnter(s)) {
       
  1995                         unsafe.monitorExit(s);
       
  1996                         Thread.sleep(1);
  1986                     }
  1997                     }
  1987                 }
  1998                 }
  1988                 p.destroy();
  1999                 p.destroy();
  1989                 thread.join();
  2000                 thread.join();
  1990             }
  2001             }