src/solaris/classes/java/lang/UNIXProcess.java.solaris

Print this page

        

*** 163,182 **** throw new IllegalThreadStateException("process hasn't exited"); } return exitcode; } ! private static native void destroyProcess(int pid); ! public synchronized void destroy() { // There is a risk that pid will be recycled, causing us to // kill the wrong process! So we only terminate processes // that appear to still be running. Even with this check, // there is an unavoidable race condition here, but the window // is very small, and OSes try hard to not recycle pids too // soon, so this is quite safe. if (!hasExited) ! destroyProcess(pid); try { stdin_stream.close(); if (stdout_inner_stream != null) stdout_inner_stream.closeDeferred(stdout_stream); if (stderr_stream instanceof DeferredCloseInputStream) --- 163,182 ---- throw new IllegalThreadStateException("process hasn't exited"); } return exitcode; } ! private static native void destroyProcess(int pid, boolean force); ! private synchronized void destroy(boolean force) { // There is a risk that pid will be recycled, causing us to // kill the wrong process! So we only terminate processes // that appear to still be running. Even with this check, // there is an unavoidable race condition here, but the window // is very small, and OSes try hard to not recycle pids too // soon, so this is quite safe. if (!hasExited) ! destroyProcess(pid, force); try { stdin_stream.close(); if (stdout_inner_stream != null) stdout_inner_stream.closeDeferred(stdout_stream); if (stderr_stream instanceof DeferredCloseInputStream)
*** 184,193 **** --- 184,209 ---- .closeDeferred(stderr_stream); } catch (IOException e) { // ignore } } + + public void destroy() { + destroy(false); + } + + public Process destroyForcibly() { + destroy(true); + return this; + } + + @Override + public boolean isAlive() { + synchronized (this) { + return !hasExited; + } + } // A FileInputStream that supports the deferment of the actual close // operation until the last pending I/O operation on the stream has // finished. This is required on Solaris because we must close the stdin // and stdout streams in the destroy method in order to reclaim the