Home » Community » Newbie corner » Stopping ReadStdIn() function  
	
		
		
			| Re: Stopping ReadStdIn() function [message #57031 is a reply to message #57030] | 
			Sun, 16 May 2021 20:53    | 
		 
		
			
				
				
				
					
						  
						Oblivion
						 Messages: 1241 Registered: August 2007 
						
					 | 
					Senior Contributor  | 
					 | 
		 
		 
	 | 
 
	
		Hello xemuth, 
 
Have you tried to set the boolean value, using signal api (sigaction, to be specific)? 
 
#include <Core/Core.h>
#include <signal.h>
using namespace Upp;
static std::atomic<bool> done(false);
static void SecureStop(int) {  done = true; }
CONSOLE_APP_MAIN
{
    String s;
    struct sigaction sa;
    Zero(sa);
    sa.sa_handler = &SecureStop;
    sigaction(SIGINT, &sa, nullptr);
	
	while(s != "exit" && !done) {
		s = ReadStdIn();
	}
 	if(done) {
		Cout() << "SIGINT!" << "\n";
	}
}
 
 
Is this what you need? 
 
Best regards, 
Oblivion
		
		
  Github page: https://github.com/ismail-yilmaz 
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
Goto Forum:
 
 Current Time: Tue Nov 04 10:01:33 CET 2025 
 Total time taken to generate the page: 0.12621 seconds 
 |