Skip to content

Commit

Permalink
Used Wait Function in pause.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin S committed Jan 5, 2025
1 parent 2a3ebc2 commit aaf109d
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions examples/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,15 @@

#include <sigfn.hpp>
#include <iostream>
#include <thread>

int main(int argc, const char **argv)
{
bool loop;
// set callback for SIGINT
sigfn::handle(SIGINT, [&](int signum) {
std::cout << std::endl << "Received signal: " << signum << std::endl;
loop = false;
});

// notify user that the program is "paused"
std::cout << "Paused. Press Ctrl+C to exit." << std::endl;

// sleep loop until we receive the signal
loop = true;
while(loop)
{
// sleep for 100ms
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
sigfn::wait({SIGINT});

std::cout << std::endl << "Received signal: SIGINT" << std::endl;

return 0;
}

0 comments on commit aaf109d

Please sign in to comment.