Home » Community » Newbie corner » Stopping ReadStdIn() function  
	
		
		
			| Re: Stopping ReadStdIn() function [message #57035 is a reply to message #57031] | 
			Mon, 17 May 2021 09:28    | 
		 
		
			
				
				
				  | 
					
						  
						Xemuth
						 Messages: 387 Registered: August 2018  Location: France
						
					 | 
					Senior Member  | 
					 | 
		 
		 
	 | 
 
	
		Hello Oblivion, Thanks for your help. 
 
In my actual code I'm doing this :  
CV2DServer* serverPtr;
CONSOLE_APP_MAIN
{
	StdLogSetup(LOG_COUT | LOG_FILE | LOG_TIMESTAMP);
	CV2DServer server(LISTENING_PORT, TICK_RATE);
	serverPtr = &server;
	std::signal(SIGINT,static_cast<__p_sig_fn_t>([](int s)->void{serverPtr->StopServer();}));
	server.StartServer();
}
 
It is a bit different from your approch but I guess it is partially equal.  
The probleme is, in my StartServer which is equal to this : 
void CV2DServer::StartServer(){
	serverThread.Start(THISBACK(ServerRoutine));
	Upp::String command;
	LOG("Command line interface ready");
	while(command != "exit" && !secureStop){
		command	= ToLower(ReadStdIn());
		Cout() << ProcessCommandLine(command);
	}
	server.Close();
	client.Close();
	serverThread.ShutdownThreads();
	serverThread.Wait();
} 
 
The ReadStdIn() block my code until I write something in console. It mean, even if I raise a SIGINT event, my code will catch it, turn the boolean secureStop to true but wont stop until I write something in console. This is problematique, that's why I'm looking for a way to stop the ReadStdIn(). 
 
I will try the way you do it after work and will update this post. But I'm pretty sure result will be the same 
		
		
		[Updated on: Mon, 17 May 2021 09:30] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 10:01:38 CET 2025 
 Total time taken to generate the page: 0.04984 seconds 
 |