aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/suicide.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/suicide.c b/src/suicide.c
index dacecc4..02ed91b 100644
--- a/src/suicide.c
+++ b/src/suicide.c
@@ -166,6 +166,9 @@ void suicide_signal_handler PARAMS((int sig));
166// displays SUSv3 signals 166// displays SUSv3 signals
167void suicide_susv3_sigs PARAMS((void)); 167void suicide_susv3_sigs PARAMS((void));
168 168
169// display C code to ignore signals
170void suicide_susv3_sigs_ignore PARAMS((void));
171
169// displays usage 172// displays usage
170void suicide_usage PARAMS((void)); 173void suicide_usage PARAMS((void));
171 174
@@ -329,7 +332,7 @@ int main(int argc, char * argv[])
329 size_t action_size; 332 size_t action_size;
330 SuicideAction ** actions; 333 SuicideAction ** actions;
331 334
332 static char short_opt[] = "chn:s:SvV"; 335 static char short_opt[] = "chin:s:SvV";
333 static struct option long_opt[] = 336 static struct option long_opt[] =
334 { 337 {
335 {"help", no_argument, 0, 'h'}, 338 {"help", no_argument, 0, 'h'},
@@ -366,6 +369,9 @@ int main(int argc, char * argv[])
366 case 'h': 369 case 'h':
367 suicide_usage(); 370 suicide_usage();
368 return(0); 371 return(0);
372 case 'i':
373 suicide_susv3_sigs_ignore();
374 return(0);
369 case 'n': 375 case 'n':
370 val = (int)strtol(optarg, NULL, 0); 376 val = (int)strtol(optarg, NULL, 0);
371 if ((suicide_find_data(&actions, &action_size, NULL, val))) 377 if ((suicide_find_data(&actions, &action_size, NULL, val)))
@@ -525,6 +531,36 @@ void suicide_susv3_sigs(void)
525 for(i = 0; i < (count+1); i++) 531 for(i = 0; i < (count+1); i++)
526 if (susv3_signals[i].name) 532 if (susv3_signals[i].name)
527 printf(" %-9s %-5i %c %s\n", susv3_signals[i].name, susv3_signals[i].number, susv3_signals[i].action, susv3_signals[i].desc); 533 printf(" %-9s %-5i %c %s\n", susv3_signals[i].name, susv3_signals[i].number, susv3_signals[i].action, susv3_signals[i].desc);
534 printf
535 (
536 "Actions:\n"
537 " T Abnormal termination of the process. The process is terminated \n"
538 " with all the consequences of _exit() except that the status made\n"
539 " available to wait() and waitpid() indicates abnormal termination\n"
540 " by the specified signal.\n"
541 " A Abnormal termination of the process. Additionally, implementation\n"
542 " defined abnormal termination actions, such as creation of a core file,\n"
543 " may occur.\n"
544 " I Ignore the signal.\n"
545 " S Stop the process.\n"
546 " C Continue the process, if it is stopped; otherwise, ignore the signal.\n"
547 );
548 return;
549}
550
551
552/// displays SUSv3 signals
553void suicide_susv3_sigs_ignore(void)
554{
555 size_t count;
556 size_t i;
557 for(i = 0; susv3_signals[i].desc; i++);
558 count = i;
559 qsort(&susv3_signals, count, sizeof(SuicideData), (int (*)(const void *, const void *))suicide_cmp_val);
560 printf("// ignore SUSv3 signals\n");
561 for(i = 0; i < (count+1); i++)
562 if (susv3_signals[i].name)
563 printf("singal(%s, SIG_IGN);\n", susv3_signals[i].name);
528 return; 564 return;
529} 565}
530 566
@@ -538,6 +574,7 @@ void suicide_usage(void)
538 // PACKAGE_BUGREPORT 574 // PACKAGE_BUGREPORT
539 printf(_("Usage: %s [OPTIONS]\n" 575 printf(_("Usage: %s [OPTIONS]\n"
540 " -c attempt to catch signals\n" 576 " -c attempt to catch signals\n"
577 " -i print C code to ignore signals\n"
541 " -h, --help print this help and exit\n" 578 " -h, --help print this help and exit\n"
542 " -n signum signal number to send\n" 579 " -n signum signal number to send\n"
543 " -s sigspec signal name to send\n" 580 " -s sigspec signal name to send\n"