@@ -123,6 +123,7 @@ public ProcessGuestLauncher(string language, ILogger logger, FileLoggerProvider?
123123
124124 AddEvent ( activity , ProfilingTelemetry . Events . GuestProcessStart ) ;
125125 process . Start ( ) ;
126+ _logger . LogDebug ( "{Language} guest process {ProcessId} started: {Command}" , _language , process . Id , resolvedCommandPath ) ;
126127 activity ? . SetTag ( TelemetryConstants . Tags . ProcessPid , process . Id ) ;
127128 AddEvent ( activity , ProfilingTelemetry . Events . GuestProcessStarted , TelemetryConstants . Tags . ProcessPid , process . Id ) ;
128129 if ( afterLaunchAsync is not null )
@@ -135,7 +136,12 @@ public ProcessGuestLauncher(string language, ILogger logger, FileLoggerProvider?
135136
136137 try
137138 {
138- await process . WaitForExitAsync ( cancellationToken ) ;
139+ var waitForExitTask = process . WaitForExitAsync ( cancellationToken ) ;
140+
141+ using var _ = cancellationToken . Register ( ( ) =>
142+ _logger . LogInformation ( "Cancellation requested while waiting for {Language} guest process {ProcessId} to exit" , _language , process . Id ) ) ;
143+
144+ await waitForExitTask . ConfigureAwait ( false ) ;
139145 }
140146 catch ( OperationCanceledException )
141147 {
@@ -152,6 +158,7 @@ public ProcessGuestLauncher(string language, ILogger logger, FileLoggerProvider?
152158 // the redirected output streams have time to drain.
153159 if ( ! process . HasExited )
154160 {
161+ _logger . LogInformation ( "Killing {Language} guest process tree {ProcessId}" , _language , process . Id ) ;
155162 try
156163 {
157164 process . Kill ( entireProcessTree : true ) ;
@@ -161,10 +168,17 @@ public ProcessGuestLauncher(string language, ILogger logger, FileLoggerProvider?
161168 _logger . LogDebug ( killEx , "Failed to kill guest process {ProcessId} after cancellation" , process . Id ) ;
162169 }
163170 }
171+ else
172+ {
173+ _logger . LogDebug ( "{Language} guest process {ProcessId} already exited before kill" , _language , process . Id ) ;
174+ }
164175
176+ _logger . LogDebug ( "Waiting for {Language} guest process {ProcessId} to exit after kill" , _language , process . Id ) ;
165177 await process . WaitForExitAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
166178 }
167179
180+ _logger . LogDebug ( "{Language} guest process {ProcessId} exited with code {ExitCode}" , _language , process . Id , process . ExitCode ) ;
181+
168182 activity ? . SetTag ( TelemetryConstants . Tags . ProcessExitCode , process . ExitCode ) ;
169183 AddEvent ( activity , ProfilingTelemetry . Events . GuestProcessExited , TelemetryConstants . Tags . ProcessExitCode , process . ExitCode ) ;
170184
0 commit comments