Based on http://stackoverflow.com/a/1173396
| 369 | |
| 370 | // Based on http://stackoverflow.com/a/1173396 |
| 371 | void Process::kill(bool /*force*/) noexcept { |
| 372 | std::lock_guard<std::mutex> lock(close_mutex); |
| 373 | if(data.id > 0 && !closed) { |
| 374 | HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); |
| 375 | if(snapshot) { |
| 376 | PROCESSENTRY32 process; |
| 377 | ZeroMemory(&process, sizeof(process)); |
| 378 | process.dwSize = sizeof(process); |
| 379 | if(Process32First(snapshot, &process)) { |
| 380 | do { |
| 381 | if(process.th32ParentProcessID == data.id) { |
| 382 | HANDLE process_handle = OpenProcess(PROCESS_TERMINATE, FALSE, process.th32ProcessID); |
| 383 | if(process_handle) { |
| 384 | TerminateProcess(process_handle, 2); |
| 385 | CloseHandle(process_handle); |
| 386 | } |
| 387 | } |
| 388 | } while(Process32Next(snapshot, &process)); |
| 389 | } |
| 390 | CloseHandle(snapshot); |
| 391 | } |
| 392 | TerminateProcess(data.handle, 2); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | // Based on http://stackoverflow.com/a/1173396 |
| 397 | void Process::kill(id_type id, bool /*force*/) noexcept { |