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

Capture OS signals for proper cleanup #258

Open
sean-gilliam opened this issue Mar 12, 2024 · 0 comments
Open

Capture OS signals for proper cleanup #258

sean-gilliam opened this issue Mar 12, 2024 · 0 comments

Comments

@sean-gilliam
Copy link
Collaborator

Since Riftshadow has several threads / connections open, we should consider capturing at least the following signals using signal or sigaction.

  • SIGINT : processed when Ctrl+C is used.
  • SIGTERM : processed when kill -9 and the like are used
  • SIGUSR1 : (optional) processed when reloading a configuration

There may be others. These are the ones that spring to mind though. Note that sigaction is Linux-only I believe.

Example:

int main(void)
{
	signal(SIGINT, sigIntHandler);
}

void sigIntHandler(int signum)
{
   // Some database connection cleanup
   exit(1);
}
int main(void)
{
	struct sigaction psa;
    memset (&psa, 0, sizeof (psa));
    psa.sa_handler = sigIntHandler;
    sigaction (SIGINT, &psa, NULL);
}

void sigIntHandler(int signum)
{
   // Some database connection cleanup
   exit(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant