How to stop the process programmatically

I would like to ask how can I stop a process programmatically using C ++?

Thank.

+3
source share
4 answers

This is a platform dependent issue. Could you indicate the platform you are working on?

For windows you can use TerminateProcess

+4
source

It depends on the platform. On Unix, you send a process a signal with kill(2).

+3
source

Use the exitfunction to complete the call process. If you want to terminate the process without executing destructors for objects with automatic or static storage, you can use the function abort.

+3
source
#include <windows.h>
int main()
{
 system("taskkill /f /im process.exe"); 
// replace process.exe with the name of process you want to stop/kill
// /f is used to forcefully terminate the process
// /im is used for imagename or in simple word it like wildcard
 return 0;
}

Or can you go to How to kill processes by name? (Win32 API)

0
source

Source: https://habr.com/ru/post/1767599/


All Articles