You can find source code on GitHub. Fairly in most cases this is nothing but a bad design that users will want to kill you for. If you have such a requirement it is better to dig into the details, find out what real life case it is covering and implement it using best practices. Why is it so? OS provides you rich API so you can really do sort of unkillable process, but sometimes it is not a supported scenario and eventually your application will be full of bugs and even blocked by antivirus software. Native scenarios may include:.