Skip to content

Commit

Permalink
More logging in IISExpress shutdown (#6854)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym committed Jan 18, 2019
1 parent 707f06e commit 8006e2d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Servers/IIS/IntegrationTesting.IIS/src/IISExpressDeployer.cs
Expand Up @@ -453,19 +453,23 @@ private class WindowsNativeMethods
internal static extern bool PostMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
}

private static void SendStopMessageToProcess(int pid)
private void SendStopMessageToProcess(int pid)
{
Logger.LogInformation($"Sending shutdown request to {pid}");
for (var ptr = WindowsNativeMethods.GetTopWindow(IntPtr.Zero); ptr != IntPtr.Zero; ptr = WindowsNativeMethods.GetWindow(ptr, 2))
{
uint num;
WindowsNativeMethods.GetWindowThreadProcessId(ptr, out num);
if (pid == num)
WindowsNativeMethods.GetWindowThreadProcessId(ptr, out var windowProcessId);
if (pid == windowProcessId)
{
var hWnd = new HandleRef(null, ptr);
WindowsNativeMethods.PostMessage(hWnd, 0x12, IntPtr.Zero, IntPtr.Zero);
if (!WindowsNativeMethods.PostMessage(hWnd, 0x12, IntPtr.Zero, IntPtr.Zero))
{
throw new InvalidOperationException($"Unable to PostMessage to process {pid}. LastError: {Marshal.GetLastWin32Error()}");
}
return;
}
}
throw new InvalidOperationException($"Unable to find main window for process {pid}");
}

private void GracefullyShutdownProcess(Process hostProcess)
Expand Down

0 comments on commit 8006e2d

Please sign in to comment.