Disable handle inheritance for Sockets #27671
Labels
area-System.Net.Sockets
enhancement
Product code improvement that does NOT require public API changes/additions
Milestone
Some ASP.NET Core users are having issues with their server sockets being kept alive by child processes after the parent has existed. This causes issues where clients are still able to connect but no traffic is being served. Handle inheritance for Process.Start has been discussed extensively in https://github.com/dotnet/corefx/issues/306. Failing a general solution there, disabling inheritance specifically for sockets would be an improvement.
While it varies across platforms there are generally two ways to disable this inheritance. The first is to call SetHandleInformation right after creating the socket. Libuv does this on Windows, and ASP.NET Core has added this as a windows specific mitigation. Ubuntu does not appear to be affected but Mac is and it does not have this API. This approach is also not atomic.
The other way to do disable inheritance is to pass a flag directly into the native socket constructor. This isn't exposed in the managed API. This approach is more commonly available across platforms.
The text was updated successfully, but these errors were encountered: