Skip to content

Instantly share code, notes, and snippets.

@stfp
Created May 19, 2011
Embed
What would you like to do?
Java class to kill the current process using JNA
/* 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