Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1210
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


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: static
Next Topic: my TCP client/server don't work correctly
Goto Forum:
  


Current Time: Sun Jun 08 17:01:37 CEST 2025

Total time taken to generate the page: 0.04024 seconds