Skip to content

Instantly share code, notes, and snippets.

@hpoul
Created August 21, 2014 15:35
Show Gist options
  • Save hpoul/b7ab5b58c32c7dfd463d to your computer and use it in GitHub Desktop.
Save hpoul/b7ab5b58c32c7dfd463d to your computer and use it in GitHub Desktop.
NuProcessKillProblem.java
import java.util.concurrent.TimeUnit;
import com.zaxxer.nuprocess.NuAbstractProcessHandler;
import com.zaxxer.nuprocess.NuProcess;
import com.zaxxer.nuprocess.NuProcessBuilder;
public class TestSigAbrtProcess {
public static void main(String[] args) {
/*
contents of killtest.sh:
#!/bin/bash
kill -6 $$
*/
NuProcessBuilder processBuilder = new NuProcessBuilder("/Users/herbert/bin/killtest.sh");
processBuilder.setProcessListener(new NuAbstractProcessHandler() {
@Override
public void onStart(NuProcess nuProcess) {
super.onStart(nuProcess);
System.out.println("Started process");
}
@Override
public void onExit(int statusCode) {
super.onExit(statusCode);
System.out.println("Command exited with exit code " + statusCode);
}
});
NuProcess process = processBuilder.start();
try {
process.waitFor(0, TimeUnit.DAYS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment