MCPcopy Create free account
hub / github.com/boostorg/build / kill_process_tree

Function kill_process_tree

src/engine/execnt.cpp:986–1017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984 */
985
986static void kill_process_tree( DWORD const pid, HANDLE const process )
987{
988 HANDLE const process_snapshot_h = CreateToolhelp32Snapshot(
989 TH32CS_SNAPPROCESS, 0 );
990 if ( INVALID_HANDLE_VALUE != process_snapshot_h )
991 {
992 BOOL ok = TRUE;
993 PROCESSENTRY32 pinfo;
994 pinfo.dwSize = sizeof( PROCESSENTRY32 );
995 for (
996 ok = Process32First( process_snapshot_h, &pinfo );
997 ok == TRUE;
998 ok = Process32Next( process_snapshot_h, &pinfo ) )
999 {
1000 if ( pinfo.th32ParentProcessID == pid )
1001 {
1002 /* Found a child, recurse to kill it and anything else below it.
1003 */
1004 HANDLE const ph = OpenProcess( PROCESS_ALL_ACCESS, FALSE,
1005 pinfo.th32ProcessID );
1006 if ( ph )
1007 {
1008 kill_process_tree( pinfo.th32ProcessID, ph );
1009 CloseHandle( ph );
1010 }
1011 }
1012 }
1013 CloseHandle( process_snapshot_h );
1014 }
1015 /* Now that the children are all dead, kill the root. */
1016 TerminateProcess( process, -2 );
1017}
1018
1019
1020static double creation_time( HANDLE const process )

Callers 1

try_kill_oneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected