31 char *pch =
"<unknown>";
33 assert(signal_info != NULL);
35 sig = signal_info->si_signo;
43 skn_logger(
SD_NOTICE,
"%s received: Requesting IP Address Info reload => [pid=%d, uid=%d]", strsignal(sig), signal_info->si_pid,
47 switch (signal_info->si_code) {
49 pch =
"kill(2) or raise(3)";
52 pch =
"Sent by the kernel.";
58 pch =
"POSIX timer expired";
61 pch =
"POSIX message queue state changed";
64 pch =
"AIO completed";
70 pch =
"tkill(2) or tgkill(2)";
76 skn_logger(
SD_NOTICE,
"%s received from => %s ?[pid=%d, uid=%d] signaling application shutdown.", strsignal(sig), pch, signal_info->si_pid, signal_info->si_uid);
80 switch (signal_info->si_code) {
82 pch =
"child has exited";
85 pch =
"child was killed";
88 pch =
"child terminated abnormally";
91 pch =
"traced child has trapped";
94 pch =
"child has stopped";
97 pch =
"stopped child has continued";
103 skn_logger(
SD_NOTICE,
"%s received for pid => %d, w/rc => %d for this reason => %s {Ignored}", strsignal(sig), signal_info->si_pid,
104 signal_info->si_status, pch);
112 switch (signal_info->si_code) {
114 pch =
"kill(2) or raise(3)";
117 pch =
"Sent by the kernel.";
123 pch =
"POSIX timer expired";
126 pch =
"POSIX message queue state changed";
129 pch =
"AIO completed";
132 pch =
"queued SIGIO";
135 pch =
"tkill(2) or tgkill(2)";
141 skn_logger(
SD_NOTICE,
"%s received from => %s ?[pid=%d, uid=%d]{Exiting}", strsignal(sig), pch, signal_info->si_pid, signal_info->si_uid);
163 siginfo_t signal_info;
167 long *threadC = (
long *)l_thread_complete;
173 sigfillset(&signal_set);
174 skn_logger(
SD_NOTICE,
"SignalManager: Startup Successful...");
179 sig = sigwaitinfo(&signal_set, &signal_info);
181 if (errno == EAGAIN) {
184 skn_logger(
SD_WARNING,
"SignalManager: sigwaitinfo() returned an error => {%s}", strerror(errno));
194 pthread_sigmask(SIG_UNBLOCK, &signal_set, NULL);
196 skn_logger(
SD_NOTICE,
"SignalManager: Thread Shutdown Complete.");
200 pthread_exit((
void *) (
long int) sig);
211 int rc = EXIT_SUCCESS;
216 skn_logger(
SD_WARNING,
"shutdown caused by application!");
218 if (*l_thread_complete != 0) {
219 pthread_cancel(sig_thread);
222 skn_logger(
SD_WARNING,
"Collecting (cleanup) threads.");
223 pthread_join(sig_thread, &trc);
226 skn_logger(
SD_NOTICE,
"Collecting signal thread's return code.");
227 pthread_join(sig_thread, &trc);
228 skn_logger(
SD_NOTICE,
"Signal thread was ended by a %d:%s signal.",
gi_exit_flag, strsignal((
int) (
long int) trc));
230 pthread_sigmask(SIG_UNBLOCK, psignal_set, NULL);
241 sigfillset(psignal_set);
242 pthread_sigmask(SIG_BLOCK, psignal_set, NULL);
246 skn_logger(
SD_ERR,
"Create signal thread failed: %d:%s", errno, strerror(errno));
247 pthread_sigmask(SIG_UNBLOCK, psignal_set, NULL);
248 i_thread_rc = EXIT_FAILURE;
static int skn_signal_manager_process_signals(siginfo_t *signal_info)
int skn_signal_manager_startup(pthread_t *psig_thread, sigset_t *psignal_set, long *l_thread_complete)
static void * skn_signal_manager_handler_thread(void *l_thread_complete)
int skn_signal_manager_shutdown(pthread_t sig_thread, sigset_t *psignal_set, long *l_thread_complete)
sig_atomic_t gi_exit_flag