Esempio n. 1
0
 private static void Kill(int processId)
 {
     if (PlatformUtilities.IsLinux || PlatformUtilities.IsOSX)
     {
         const int sigkill = 9;
         UnixNativeMethods.Kill(processId, sigkill);
     }
     else if (PlatformUtilities.IsWindows)
     {
         try
         {
             TryGetProcessById(processId)?.Kill();
         }
         catch (Exception) { }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Esempio n. 2
0
 public static bool IsProcessRunning(int processId)
 {
     if (PlatformUtilities.IsLinux || PlatformUtilities.IsOSX)
     {
         return UnixNativeMethods.GetPGid(processId) >= 0;
     }
     else if (PlatformUtilities.IsWindows)
     {
         try
         {
             return !TryGetProcessById(processId)?.HasExited ?? false;
         }
         catch (Exception)
         {
             return false;
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }