Created
May 19, 2011 03:21
-
-
Save stfp/980127 to your computer and use it in GitHub Desktop.
Java class to kill the current process using JNA
This file contains hidden or 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
/* Requires JNA | |
* Get jna.jar here: http://java.net/projects/jna/sources/svn/show/trunk/jnalib/dist | |
*/ | |
import com.sun.jna.Library; | |
import com.sun.jna.Native; | |
public class SelfKiller | |
{ | |
private interface CLibrary extends Library | |
{ | |
CLibrary INSTANCE = (CLibrary) Native.loadLibrary("c", CLibrary.class); | |
int getpid (); | |
void kill(int pid, int signal); | |
} | |
public static void killSelf() | |
{ | |
int pid = CLibrary.INSTANCE.getpid(); | |
CLibrary.INSTANCE.kill(pid, 9); | |
} | |
public static void main(String[] args) | |
{ | |
SelfKiller.killSelf(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment