mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-18 00:31:30 +00:00
new(userspace/falco): handle SIGHUP and SIGINT in the main process not in the spawned threads (grpc server)
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
parent
3df53f6092
commit
21e588394f
@ -21,7 +21,8 @@ limitations under the License.
|
|||||||
#else
|
#else
|
||||||
#include <grpc++/grpc++.h>
|
#include <grpc++/grpc++.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h> // sleep
|
#include <signal.h> // pthread_sigmask
|
||||||
|
#include <unistd.h> // sleep, _exit
|
||||||
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
#include "grpc_server.h"
|
#include "grpc_server.h"
|
||||||
@ -188,8 +189,26 @@ void read(const std::string& filename, std::string& data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" void handle_signal(int signum)
|
||||||
|
{
|
||||||
|
// todo > print "Got signal << sigenum << : exiting...");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
void falco_grpc_server::run()
|
void falco_grpc_server::run()
|
||||||
{
|
{
|
||||||
|
// Handle SIGHUP and SIGINT in the main process.
|
||||||
|
// Not in the spawned threads.
|
||||||
|
sigset_t set;
|
||||||
|
sigemptyset(&set);
|
||||||
|
sigaddset(&set, SIGHUP);
|
||||||
|
sigaddset(&set, SIGINT);
|
||||||
|
pthread_sigmask(SIG_UNBLOCK, &set, nullptr);
|
||||||
|
struct sigaction action;
|
||||||
|
action.sa_handler = handle_signal;
|
||||||
|
sigaction(SIGHUP, &action, nullptr);
|
||||||
|
sigaction(SIGINT, &action, nullptr);
|
||||||
|
|
||||||
string private_key;
|
string private_key;
|
||||||
string cert_chain;
|
string cert_chain;
|
||||||
string root_certs;
|
string root_certs;
|
||||||
|
Loading…
Reference in New Issue
Block a user