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

Function kill_process_tree

src/engine/execnt.c:1017–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1015 */
1016
1017static void kill_process_tree( DWORD const pid, HANDLE const process )
1018{
1019 HANDLE const process_snapshot_h = CreateToolhelp32Snapshot(
1020 TH32CS_SNAPPROCESS, 0 );
1021 if ( INVALID_HANDLE_VALUE != process_snapshot_h )
1022 {
1023 BOOL ok = TRUE;
1024 PROCESSENTRY32 pinfo;
1025 pinfo.dwSize = sizeof( PROCESSENTRY32 );
1026 for (
1027 ok = Process32First( process_snapshot_h, &pinfo );
1028 ok == TRUE;
1029 ok = Process32Next( process_snapshot_h, &pinfo ) )
1030 {
1031 if ( pinfo.th32ParentProcessID == pid )
1032 {
1033 /* Found a child, recurse to kill it and anything else below it.
1034 */
1035 HANDLE const ph = OpenProcess( PROCESS_ALL_ACCESS, FALSE,
1036 pinfo.th32ProcessID );
1037 if ( ph )
1038 {
1039 kill_process_tree( pinfo.th32ProcessID, ph );
1040 CloseHandle( ph );
1041 }
1042 }
1043 }
1044 CloseHandle( process_snapshot_h );
1045 }
1046 /* Now that the children are all dead, kill the root. */
1047 TerminateProcess( process, -2 );
1048}
1049
1050
1051static double creation_time( HANDLE const process )

Callers 1

try_kill_oneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected