github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/tini/test/sigconf/sigconf-test.c (about)

     1  /*
     2  Test program to:
     3  + Ignore a few signals
     4  + Block a few signals
     5  + Exec whatever the test runner asked for
     6  */
     7  
     8  #include <stdlib.h>
     9  #include <signal.h>
    10  #include <unistd.h>
    11  
    12  
    13  int main(int argc, char *argv[]) {
    14  	// Signals to ignore
    15  	signal(SIGTTOU, SIG_IGN);  // This one should still be in SigIgn (Tini touches it to ignore it, and should restore it)
    16  	signal(SIGSEGV, SIG_IGN);  // This one should still be in SigIgn (Tini shouldn't touch it)
    17  	signal(SIGINT,  SIG_IGN);  // This one should still be in SigIgn (Tini should block it to forward it, and restore it)
    18  
    19  	// Signals to block
    20  	sigset_t set;
    21  	sigemptyset(&set);
    22  	sigaddset(&set, SIGTTIN);  // This one should still be in SigIgn (Tini touches it to ignore it, and should restore it)
    23  	sigaddset(&set, SIGILL);   // This one should still be in SigIgn (Tini shouldn't touch it)
    24  	sigaddset(&set, SIGTERM);  // This one should still be in SigIgn (Tini should block it to forward it, and restore it)
    25  	sigprocmask(SIG_BLOCK, &set, NULL);
    26  
    27  	// Run whatever we were asked to run
    28  	execvp(argv[1], argv+1);
    29  }