I have a simple console application. Typically, when the main function completes, we should see the message "Press any key to close this window..." in the console.
However, this doesn't always happen. If I run the program several times, sometimes I see the message "Press any key to close this window..." in the console, indicating that the program has terminated. But sometimes I don't see this message, and the program continues running despite the string "end" being printed to the console (right before return 0;). The process also continues to exist in Task Manager.
I thought it might be the channel destructor, that something was happening in its destructor that was preventing the program from terminating, but explicitly destroying the channel by calling channel.reset(); doesn't change the situation.
What could be causing the process to hang, and how can I figure out what exactly is causing this?
My code, OS Windows 11
#include
#include
int main()
{
_putenv("GRPC_DNS_RESOLVER=native");
auto channel = grpc::CreateChannel("thishostdoesnotexists123.in:9000", grpc::InsecureChannelCredentials());
channel.reset();
std::cout << "end " << channel.use_count() << std::endl;
return 0;
}