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

Function kill_process_tree

v2/engine/execnt.c:886–917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

884 */
885
886static void kill_process_tree( DWORD const pid, HANDLE const process )
887{
888 HANDLE const process_snapshot_h = CreateToolhelp32Snapshot(
889 TH32CS_SNAPPROCESS, 0 );
890 if ( INVALID_HANDLE_VALUE != process_snapshot_h )
891 {
892 BOOL ok = TRUE;
893 PROCESSENTRY32 pinfo;
894 pinfo.dwSize = sizeof( PROCESSENTRY32 );
895 for (
896 ok = Process32First( process_snapshot_h, &pinfo );
897 ok == TRUE;
898 ok = Process32Next( process_snapshot_h, &pinfo ) )
899 {
900 if ( pinfo.th32ParentProcessID == pid )
901 {
902 /* Found a child, recurse to kill it and anything else below it.
903 */
904 HANDLE const ph = OpenProcess( PROCESS_ALL_ACCESS, FALSE,
905 pinfo.th32ProcessID );
906 if ( ph )
907 {
908 kill_process_tree( pinfo.th32ProcessID, ph );
909 CloseHandle( ph );
910 }
911 }
912 }
913 CloseHandle( process_snapshot_h );
914 }
915 /* Now that the children are all dead, kill the root. */
916 TerminateProcess( process, -2 );
917}
918
919
920static double creation_time( HANDLE const process )

Callers 1

try_kill_oneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected