Home | History | Annotate | Download | only in tests-mx32
      1 #include "tests.h"
      2 #include <signal.h>
      3 #include <stdio.h>
      4 #include <unistd.h>
      5 
      6 void sig_print(const char *signame, const int pid, const int uid)
      7 {
      8 	printf("kill(%d, %s) = 0\n"
      9 	       "--- %s {si_signo=%s, si_code=SI_USER, si_pid=%d"
     10 	       ", si_uid=%d} ---\n",
     11 	       pid, signame, signame, signame, pid, uid);
     12 }
     13 
     14 static void
     15 handler(int sig)
     16 {
     17 }
     18 
     19 int
     20 main(void)
     21 {
     22 	int sig, pid = getpid(), uid = getuid();
     23 	const struct sigaction act = { .sa_handler = handler };
     24 	sigset_t mask;
     25 	sigemptyset(&mask);
     26 
     27 	for (sig = 1; sig <= 31; sig++) {
     28 		if (sig != SIGKILL && sig != SIGSTOP) {
     29 			sigaction(sig, &act, NULL);
     30 			sigaddset(&mask, sig);
     31 		}
     32 	}
     33 	sigprocmask(SIG_UNBLOCK, &mask, NULL);
     34 
     35 	for (sig = 1; sig <= 31; sig++) {
     36 		if (sig != SIGKILL && sig != SIGSTOP) {
     37 			if (kill(pid, sig) != 0)
     38 				perror_msg_and_fail("kill: %d", sig);
     39 			sig_print(signal2name(sig), pid, uid);
     40 		}
     41 	}
     42 
     43 	puts("+++ exited with 0 +++");
     44 	return 0;
     45 }
     46