Use static globals

This commit is contained in:
madmaurice 2021-01-15 20:22:22 +01:00
parent 2f56f84214
commit d0feff88b1

5
main.c
View file

@ -11,8 +11,10 @@
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
static
pid_t pid_child; pid_t pid_child;
static
void drop_root(void) void drop_root(void)
{ {
/// Drop root privileges /// Drop root privileges
@ -31,7 +33,7 @@ void drop_root(void)
errx(1, "Sanity check failed. Able to regain root"); errx(1, "Sanity check failed. Able to regain root");
} }
struct sigaction forward_signal_descriptor; static
void forward_signal(int sig) void forward_signal(int sig)
{ {
if (kill(pid_child, sig) == -1) if (kill(pid_child, sig) == -1)
@ -43,6 +45,7 @@ void forward_signal(int sig)
int main(int argc, char* const* argv) int main(int argc, char* const* argv)
{ {
struct sigaction forward_signal_descriptor;
forward_signal_descriptor.sa_flags = SA_RESTART; forward_signal_descriptor.sa_flags = SA_RESTART;
forward_signal_descriptor.sa_handler = &forward_signal; forward_signal_descriptor.sa_handler = &forward_signal;