public static string GetCommandLine(System.Diagnostics.Process process) { if (System.Environment.OSVersion.Platform == System.PlatformID.Unix) { return(UnixProcess.GetCommandLine(process)); } return(WindowsProcess.GetCommandLine(process)); } // End Function GetCommandLine
} // End Function GetCommandLine public static void KillProcessAndChildren(int pid) { if (System.Environment.OSVersion.Platform == System.PlatformID.Unix) { UnixProcess.KillProcessAndChildren(pid); } else { WindowsProcess.KillProcessAndChildren(pid); } } // End Sub KillProcessAndChildren
public static void UnhandledExceptionHandler(object ex) { try { if (ex == null) { var stackTrace = Environment.StackTrace; Logger.Error("Unhandled exception but did not have exception object. Stack trace:", stackTrace); return; } if (!(ex is Exception)) { Logger.Error("Unhandled exception. Object was not exception. {0}", ex); return; } var aggregateException = ex as AggregateException; if (aggregateException != null) { Logger.ErrorException("Unhandled exception aggregate", aggregateException); foreach (var innerException in aggregateException.Flatten().InnerExceptions) { Logger.ErrorException("Aggregate inner exception", innerException); } return; } Logger.ErrorException("Unhandled exception", (Exception)ex); } finally { if (Global.IsRunningOnMono()) { UnixProcess.GetCurrentProcess().Kill(); } else { Environment.FailFast("Unhandled exception.. failing fast."); } } }