File tree Expand file tree Collapse file tree
Solutions/Corvus.Testing.AzureFunctions/Corvus/Testing/AzureFunctions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ namespace Corvus.Testing.AzureFunctions
1313 using System . Net . Http ;
1414 using System . Net . NetworkInformation ;
1515 using System . Net . Sockets ;
16+ using System . Runtime . InteropServices ;
1617 using System . Threading ;
1718 using System . Threading . Tasks ;
1819
@@ -198,12 +199,15 @@ private static void KillProcessAndChildren(int pid)
198199 return ;
199200 }
200201
201- using ( var searcher =
202- new ManagementObjectSearcher ( "Select * From Win32_Process Where ParentProcessID=" + pid ) )
202+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
203203 {
204- foreach ( ManagementObject mo in searcher . Get ( ) . Cast < ManagementObject > ( ) )
204+ using ( var searcher =
205+ new ManagementObjectSearcher ( "Select * From Win32_Process Where ParentProcessID=" + pid ) )
205206 {
206- KillProcessAndChildren ( Convert . ToInt32 ( mo [ "ProcessID" ] ) ) ;
207+ foreach ( ManagementObject mo in searcher . Get ( ) . Cast < ManagementObject > ( ) )
208+ {
209+ KillProcessAndChildren ( Convert . ToInt32 ( mo [ "ProcessID" ] ) ) ;
210+ }
207211 }
208212 }
209213
@@ -228,7 +232,14 @@ private static void KillProcessAndChildren(int pid)
228232
229233 try
230234 {
231- proc . Kill ( ) ;
235+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
236+ {
237+ proc . Kill ( ) ;
238+ }
239+ else
240+ {
241+ proc . Kill ( entireProcessTree : true ) ;
242+ }
232243 }
233244 catch ( Win32Exception x )
234245 when ( x . ErrorCode == E_ACCESSDENIED )
You can’t perform that action at this time.
0 commit comments