Skip to content

Added shutdown handler for Classic Server #8165

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

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/remote/server/os/posix/inet_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const char* TEMP_DIR = "/tmp";

static void set_signal(int, void (*)(int));
static void signal_handler(int);
static void shutdown_handler(int);

static TEXT protocol[128];
static int INET_SERVER_start = 0;
Expand Down Expand Up @@ -314,6 +315,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
// activate paths set with -e family of switches
ISC_set_prefix(0, 0);

// set shutdown signals handler for listener
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add this handlers in super & superclassic modes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's only relevant to classic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a condition

if (standaloneClassic)
{
set_signal(SIGTERM, shutdown_handler);
set_signal(SIGINT, shutdown_handler);
}

// ignore some signals
set_signal(SIGPIPE, signal_handler);
set_signal(SIGUSR1, signal_handler);
Expand Down Expand Up @@ -507,6 +515,13 @@ int CLIB_ROUTINE main( int argc, char** argv)
}
}

// set default handlers for child processes
if (standaloneClassic)
{
signal(SIGTERM, SIG_DFL);
signal(SIGINT, SIG_DFL);
}

if (classic)
{
port = INET_server(channel);
Expand Down Expand Up @@ -631,6 +646,23 @@ static void signal_handler(int)
++INET_SERVER_start;
}

static void shutdown_handler(int)
{
/**************************************
*
* s h u t d o w n _ h a n d l e r
*
**************************************
*
* Functional description
* Forward sigterm signal to all child processes.
*
**************************************/

kill(-1 * getpid(), SIGTERM);

exit(FINI_OK);
}

#ifdef FB_RAISE_LIMITS
static void raiseLimit(int resource)
Expand Down
Loading