Created
August 21, 2014 15:35
-
-
Save hpoul/b7ab5b58c32c7dfd463d to your computer and use it in GitHub Desktop.
NuProcessKillProblem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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