From: Andrew Au Date: Mon, 6 May 2019 18:01:28 +0000 (-0700) Subject: Terminate dotnet-trace when the runtime closes the eventpipe X-Git-Tag: submit/tizen/20190813.035844~6^2^2~42 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4653f450481dea6011e730623310e35cc9e22ae4;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Terminate dotnet-trace when the runtime closes the eventpipe --- diff --git a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs index 4361d5b64..6d42a03dd 100644 --- a/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs +++ b/src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs @@ -86,6 +86,7 @@ namespace Microsoft.Diagnostics.Tools.Trace providers: providerCollection); var shouldExit = new ManualResetEvent(false); + var terminated = false; ulong sessionId = 0; using (Stream stream = EventPipeClient.CollectTracing(processId, configuration, out sessionId)) @@ -118,6 +119,8 @@ namespace Microsoft.Diagnostics.Tools.Trace Debug.WriteLine($"PACKET: {Convert.ToBase64String(buffer, 0, nBytesRead)} (bytes {nBytesRead})"); } + terminated = true; + shouldExit.Set(); } }); collectingTask.Start(); @@ -132,7 +135,10 @@ namespace Microsoft.Diagnostics.Tools.Trace while (!Console.KeyAvailable && !shouldExit.WaitOne(250)) { } } while (!shouldExit.WaitOne(0) && Console.ReadKey(true).Key != ConsoleKey.Enter); - EventPipeClient.StopTracing(processId, sessionId); + if (!terminated) + { + EventPipeClient.StopTracing(processId, sessionId); + } collectingTask.Wait(); }