mirror of
https://github.com/corda/corda.git
synced 2025-01-19 11:16:54 +00:00
implement Process.destroy
This commit is contained in:
parent
76f57fc931
commit
90dc552463
@ -279,6 +279,11 @@ Java_java_lang_Runtime_waitFor(JNIEnv* e, jclass, jlong pid, jlong tid)
|
|||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
Java_java_lang_Runtime_kill(JNIEnv*, jclass, jlong pid) {
|
||||||
|
TerminateProcess(reinterpret_cast<HANDLE>(pid), 1);
|
||||||
|
}
|
||||||
|
|
||||||
Locale getLocale() {
|
Locale getLocale() {
|
||||||
const char* lang = "";
|
const char* lang = "";
|
||||||
const char* reg = "";
|
const char* reg = "";
|
||||||
@ -466,6 +471,11 @@ Java_java_lang_Runtime_waitFor(JNIEnv*, jclass, jlong pid, jlong)
|
|||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" JNIEXPORT void JNICALL
|
||||||
|
Java_java_lang_Runtime_kill(JNIEnv*, jclass, jlong pid) {
|
||||||
|
kill((pid_t)pid, SIGTERM);
|
||||||
|
}
|
||||||
|
|
||||||
Locale getLocale() {
|
Locale getLocale() {
|
||||||
Locale fallback;
|
Locale fallback;
|
||||||
|
|
||||||
|
@ -122,6 +122,8 @@ public class Runtime {
|
|||||||
|
|
||||||
private static native void load(String name, boolean mapName);
|
private static native void load(String name, boolean mapName);
|
||||||
|
|
||||||
|
private static native void kill(long pid);
|
||||||
|
|
||||||
public native void gc();
|
public native void gc();
|
||||||
|
|
||||||
public native void exit(int code);
|
public native void exit(int code);
|
||||||
@ -147,7 +149,7 @@ public class Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
throw new RuntimeException("not implemented");
|
kill(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream getInputStream() {
|
public InputStream getInputStream() {
|
||||||
|
31
test/Processes.java
Normal file
31
test/Processes.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class Processes {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
final Process p = Runtime.getRuntime().exec("sleep 10");
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch(InterruptedException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
p.destroy();
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
try {
|
||||||
|
p.waitFor();
|
||||||
|
} catch(InterruptedException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
long stop = System.currentTimeMillis();
|
||||||
|
if(stop - start > 5000) {
|
||||||
|
throw new RuntimeException("test failed; we didn't kill the process...");
|
||||||
|
}
|
||||||
|
} catch(IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user