Skip to content
Merged
Changes from 1 commit
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
26 changes: 26 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,10 @@ 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

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 +512,10 @@ int CLIB_ROUTINE main( int argc, char** argv)
}
}

// set default handlers for child processes
signal(SIGTERM, SIG_DFL);
signal(SIGINT, SIG_DFL);

if (classic)
{
port = INET_server(channel);
Expand Down Expand Up @@ -631,6 +640,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