Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More logging in IISExpress shutdown #6854

Merged
merged 1 commit into from Jan 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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