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

Signal Handler should not use non async-signal-safe functions #530

Open
azeey opened this issue Aug 17, 2023 · 0 comments
Open

Signal Handler should not use non async-signal-safe functions #530

azeey opened this issue Aug 17, 2023 · 0 comments

Comments

@azeey
Copy link
Contributor

azeey commented Aug 17, 2023

Locking mutexes and printing to the console using gzdbg are not considered async-signal-safe and could cause the application to hang or go into an undefined state.

void SignalHandlerPrivate::OnSignal(int _sig)
{
std::lock_guard<std::mutex> lock(this->cbMutex);
gzdbg << "Received signal[" << _sig << "].\n";
for (std::function<void(int)> cb : this->callbacks)
cb(_sig);
}

Potential implementation reference: https://github.com/sphenical/signal-handler/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

No branches or pull requests

1 participant