Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I release sources before exit #938

Open
xstar2091 opened this issue Nov 7, 2024 · 2 comments
Open

How can I release sources before exit #938

xstar2091 opened this issue Nov 7, 2024 · 2 comments
Labels
question Issue can be closed by providing information

Comments

@xstar2091
Copy link

made a http server var CrowCpp. It crashed when exit the server by Ctrl+C if handler was already running. I tried to stop the handler used atexit and signal like this

#include <csignal>
#include <crow.h>

void OnExitHandler()
{
// release sources here
}

void OnSignalHandler(int signum)
{
    if (signum == SIGINT)
    {
        OnExitHandler();
    }
}

int main()
{
    std::atexit(&OnExitHandler);
    signal(SIGINT, &OnSignalHandler);

    crow::SimpleApp app;

    // http server here

    app.port(conf->server().port)
       .multithreaded()
       .loglevel(crow::LogLevel::Warning)
       .run();
    return 0;
}

But it did not work. SIGINT signal was not processed in my handler function "OnSignalHandler".

So, How can I stop the running handler and release the sources before exit?

@gittiver gittiver added the question Issue can be closed by providing information label Nov 7, 2024
@xstar2091
Copy link
Author

My pr is blocked. The tests failed unfortunately. I don't have a Mac or Windows device, so there's no way to troubleshoot these errors.

The test was canceld on Windows because of the "Prepare dependencies" went error.
The test failed on task_timer on Macos-13. I dont have mac to roubleshoot the error and I think it is not related to the signal fix code.

@gittiver
Copy link
Member

its a timing issue on osx, i restarted the job. I already have a bug and branch for it but not done yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Issue can be closed by providing information
Projects
None yet
Development

No branches or pull requests

2 participants