| 606 ); |
607 ); |
| 607 |
608 |
| 608 /* we have to convert the message (UTF-8 to console |
609 /* we have to convert the message (UTF-8 to console |
| 609 charset) early because after a segmentation fault |
610 charset) early because after a segmentation fault |
| 610 it's not a good practice to allocate memory */ |
611 it's not a good practice to allocate memory */ |
| |
612 error = NULL; |
| 611 segfault_message = g_locale_from_utf8(segfault_message_tmp, |
613 segfault_message = g_locale_from_utf8(segfault_message_tmp, |
| 612 -1, NULL, NULL, &error); |
614 -1, NULL, NULL, &error); |
| 613 if (segfault_message != NULL) { |
615 if (segfault_message != NULL) { |
| 614 g_free(segfault_message_tmp); |
616 g_free(segfault_message_tmp); |
| 615 } |
617 } |
| 650 if (signal_status != G_IO_STATUS_NORMAL) { |
652 if (signal_status != G_IO_STATUS_NORMAL) { |
| 651 fprintf(stderr, "Failed to set the signal channel to raw " |
653 fprintf(stderr, "Failed to set the signal channel to raw " |
| 652 "binary: %s", error->message); |
654 "binary: %s", error->message); |
| 653 exit(1); |
655 exit(1); |
| 654 } |
656 } |
| 655 g_io_add_watch(signal_channel, G_IO_IN, mainloop_sighandler, NULL); |
657 signal_channel_watcher = g_io_add_watch(signal_channel, G_IO_IN, mainloop_sighandler, NULL); |
| |
658 g_io_channel_unref(signal_channel); |
| 656 |
659 |
| 657 /* Let's not violate any PLA's!!!! */ |
660 /* Let's not violate any PLA's!!!! */ |
| 658 /* jseymour: whatever the fsck that means */ |
661 /* jseymour: whatever the fsck that means */ |
| 659 /* Robot101: for some reason things like gdm like to block * |
662 /* Robot101: for some reason things like gdm like to block * |
| 660 * useful signals like SIGCHLD, so we unblock all the ones we * |
663 * useful signals like SIGCHLD, so we unblock all the ones we * |
| 661 * declare a handler for. thanks JSeymour and Vann. */ |
664 * declare a handler for. thanks JSeymour and Vann. */ |
| 662 if (sigemptyset(&sigset)) { |
665 if (sigemptyset(&sigset)) { |
| 663 snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set"); |
666 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't initialise empty signal set"); |
| 664 perror(errmsg); |
667 perror(errmsg); |
| 665 } |
668 } |
| 666 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { |
669 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { |
| 667 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { |
670 if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { |
| 668 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching", |
671 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d for catching", |
| 669 catch_sig_list[sig_indx]); |
672 catch_sig_list[sig_indx]); |
| 670 perror(errmsg); |
673 perror(errmsg); |
| 671 } |
674 } |
| 672 if(sigaddset(&sigset, catch_sig_list[sig_indx])) { |
675 if(sigaddset(&sigset, catch_sig_list[sig_indx])) { |
| 673 snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking", |
676 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't include signal %d for unblocking", |
| 674 catch_sig_list[sig_indx]); |
677 catch_sig_list[sig_indx]); |
| 675 perror(errmsg); |
678 perror(errmsg); |
| 676 } |
679 } |
| 677 } |
680 } |
| 678 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { |
681 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { |
| 679 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { |
682 if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { |
| 680 snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore", |
683 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't set signal %d to ignore", |
| 681 ignore_sig_list[sig_indx]); |
684 ignore_sig_list[sig_indx]); |
| 682 perror(errmsg); |
685 perror(errmsg); |
| 683 } |
686 } |
| 684 } |
687 } |
| 685 |
688 |
| 686 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { |
689 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { |
| 687 snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals"); |
690 snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals"); |
| 688 perror(errmsg); |
691 perror(errmsg); |
| 689 } |
692 } |
| 690 #endif |
693 #endif |
| 691 |
694 |
| 692 /* scan command-line options */ |
695 /* scan command-line options */ |