3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1998 The LyX Team
10 * ======================================================
16 #pragma implementation
25 #include <sys/types.h>
27 #include FORMS_H_LOCATION
29 #if TIME_WITH_SYS_TIME
30 # include <sys/time.h>
34 # include <sys/time.h>
40 #ifdef HAVE_SYS_SELECT_H
41 # ifdef HAVE_STRINGS_H
42 // <strings.h> is needed at least on AIX because FD_ZERO uses bzero().
45 #include <sys/select.h>
52 #include "spellchecker.h"
56 #include "BufferView.h"
58 #include "lyx_gui_misc.h"
60 #include "support/lstrings.h"
63 #include "support/lstrings.h"
65 //#define USE_PSPELL 1
69 #include <pspell/pspell.h>
76 // Spellchecker status
86 static bool RunSpellChecker(BufferView * bv);
90 static FILE * in, * out; /* streams to communicate with ispell */
91 pid_t isp_pid = -1; // pid for the `ispell' process. Also used (RO) in
94 // the true spell checker program being used
95 enum ActualSpellChecker {ASC_ISPELL, ASC_ASPELL};
96 static ActualSpellChecker actual_spell_checker;
106 static FD_form_spell_options *fd_form_spell_options = 0;
107 FD_form_spell_check *fd_form_spell_check = 0;
109 //void sigchldhandler(int sig);
110 void sigchldhandler(pid_t pid, int *status);
112 //extern void sigchldchecker(int sig);
113 extern void sigchldchecker(pid_t pid, int *status);
122 const char * next_miss();
132 const char * isp_result::next_miss() {
133 if (str == 0 || *(e+1) == '\0') return 0;
135 e = strpbrk(b, ",\n");
144 PspellStringEmulation * els;
146 const char * next_miss();
152 delete_pspell_string_emulation(els);
156 const char * isp_result::next_miss()
158 return pspell_string_emulation_next(els);
163 const char * spell_error;
166 /***** Spellchecker options *****/
168 // Rewritten to use ordinary LyX xforms loop and OK, Apply and Cancel set,
169 // now also string. Amazing, eh? (Asger)
171 // Set (sane) values in form to current spellchecker options
172 void SpellOptionsUpdate()
174 // Alternate language
175 if (lyxrc.isp_alt_lang.empty()) {
176 lyxrc.isp_use_alt_lang = false;
178 fl_set_input(fd_form_spell_options->altlang_input,
179 lyxrc.isp_alt_lang.c_str());
181 if (lyxrc.isp_use_alt_lang) {
182 fl_set_button(fd_form_spell_options->buflang, 0);
183 fl_set_button(fd_form_spell_options->altlang, 1);
185 fl_set_button(fd_form_spell_options->buflang, 1);
186 fl_set_button(fd_form_spell_options->altlang, 0);
189 // Personal dictionary
190 if (lyxrc.isp_pers_dict.empty()) {
191 lyxrc.isp_use_pers_dict = false;
193 fl_set_input(fd_form_spell_options->perdict_input,
194 lyxrc.isp_pers_dict.c_str());
196 fl_set_button(fd_form_spell_options->perdict,
197 lyxrc.isp_use_pers_dict ? 1:0);
200 if (lyxrc.isp_esc_chars.empty()) {
201 lyxrc.isp_use_esc_chars = false;
203 fl_set_input(fd_form_spell_options->esc_chars_input,
204 lyxrc.isp_esc_chars.c_str());
206 fl_set_button(fd_form_spell_options->esc_chars,
207 lyxrc.isp_use_esc_chars ? 1:0);
210 fl_set_button(fd_form_spell_options->compounds,
211 lyxrc.isp_accept_compound ? 1 : 0);
212 fl_set_button(fd_form_spell_options->inpenc,
213 lyxrc.isp_use_input_encoding ? 1 : 0);
216 // Update spellchecker options
217 void SpellOptionsApplyCB(FL_OBJECT *, long)
219 // Build new status from form data
220 lyxrc.isp_use_alt_lang =
221 fl_get_button(fd_form_spell_options->altlang);
222 lyxrc.isp_use_pers_dict =
223 fl_get_button(fd_form_spell_options->perdict);
224 lyxrc.isp_accept_compound =
225 fl_get_button(fd_form_spell_options->compounds);
226 lyxrc.isp_use_esc_chars =
227 fl_get_button(fd_form_spell_options->esc_chars);
228 lyxrc.isp_use_input_encoding =
229 fl_get_button(fd_form_spell_options->inpenc);
231 // Update strings with data from input fields
233 fl_get_input(fd_form_spell_options->altlang_input);
234 lyxrc.isp_pers_dict =
235 fl_get_input(fd_form_spell_options->perdict_input);
236 lyxrc.isp_esc_chars =
237 fl_get_input(fd_form_spell_options->esc_chars_input);
240 SpellOptionsUpdate();
244 void SpellOptionsCancelCB(FL_OBJECT *, long)
246 fl_hide_form(fd_form_spell_options->form_spell_options);
250 void SpellOptionsOKCB(FL_OBJECT * ob, long data)
252 SpellOptionsApplyCB(ob, data);
253 SpellOptionsCancelCB(ob, data);
257 // Show spellchecker options form
258 void SpellCheckerOptions()
260 // Create form if nescessary
261 if (fd_form_spell_options == 0) {
262 fd_form_spell_options = create_form_form_spell_options();
263 // Make sure pressing the close box does not kill LyX. (RvdK)
264 fl_set_form_atclose(fd_form_spell_options->form_spell_options,
265 CancelCloseBoxCB, 0);
268 // Update form to current options
269 SpellOptionsUpdate();
271 // Focus in alternate language field
272 fl_set_focus_object(fd_form_spell_options->form_spell_options,
273 fd_form_spell_options->altlang_input);
276 if (fd_form_spell_options->form_spell_options->visible) {
277 fl_raise_form(fd_form_spell_options->form_spell_options);
279 fl_show_form(fd_form_spell_options->form_spell_options,
280 FL_PLACE_MOUSE, FL_FULLBORDER,
281 _("Spellchecker Options"));
287 /***** Spellchecker *****/
289 // Could also use a clean up. (Asger Alstrup)
292 void init_spell_checker(BufferParams const & params, string const & lang)
294 static char o_buf[BUFSIZ]; // jc: it could be smaller
295 int pipein[2], pipeout[2];
301 if(pipe(pipein) == -1 || pipe(pipeout) == -1) {
302 lyxerr << "LyX: Can't create pipe for spellchecker!" << endl;
306 if ((out = fdopen(pipein[1], "w")) == 0) {
307 lyxerr << "LyX: Can't create stream for pipe for spellchecker!"
312 if ((in = fdopen(pipeout[0], "r")) == 0) {
313 lyxerr <<"LyX: Can't create stream for pipe for spellchecker!"
318 setvbuf(out, o_buf, _IOLBF, BUFSIZ);
325 lyxerr << "LyX: Can't create child process for spellchecker!"
332 dup2(pipein[0], STDIN_FILENO);
333 dup2(pipeout[1], STDOUT_FILENO);
340 char * tmp = new char[lyxrc.isp_command.length() + 1];
341 lyxrc.isp_command.copy(tmp, lyxrc.isp_command.length());
342 tmp[lyxrc.isp_command.length()] = '\0';
345 string("-a").copy(tmp, 2); tmp[2] = '\0'; // pipe mode
348 if (lang != "default") {
350 string("-d").copy(tmp, 2); tmp[2] = '\0'; // Dictionary file
352 tmp = new char[lang.length() + 1];
353 lang.copy(tmp, lang.length()); tmp[lang.length()] = '\0';
357 if (lyxrc.isp_accept_compound) {
358 // Consider run-together words as legal compounds
360 string("-C").copy(tmp, 2); tmp[2] = '\0';
363 // Report run-together words with
364 // missing blanks as errors
366 string("-B").copy(tmp, 2); tmp[2] = '\0';
369 if (lyxrc.isp_use_esc_chars) {
370 // Specify additional characters that
371 // can be part of a word
373 string("-w").copy(tmp, 2); tmp[2] = '\0';
375 // Put the escape chars in ""s
376 string tms = "\"" + lyxrc.isp_esc_chars + "\"";
377 tmp = new char[tms.length() + 1];
378 tms.copy(tmp, tms.length()); tmp[tms.length()] = '\0';
381 if (lyxrc.isp_use_pers_dict) {
382 // Specify an alternate personal dictionary
384 string("-p").copy(tmp, 2);
387 tmp = new char[lyxrc.isp_pers_dict.length() + 1];
388 lyxrc.isp_pers_dict.copy(tmp, lyxrc.isp_pers_dict.length());
389 tmp[lyxrc.isp_pers_dict.length()] = '\0';
392 if (lyxrc.isp_use_input_encoding &&
393 params.inputenc != "default") {
394 string enc = (params.inputenc == "auto")
395 ? params.language_info->encoding()->LatexName()
397 string::size_type n = enc.length();
399 string("-T").copy(tmp, 2); tmp[2] = '\0';
400 argv[argc++] = tmp; // Input encoding
401 tmp = new char[n + 1];
409 execvp(argv[0], const_cast<char * const *>(argv));
411 // free the memory used by string::copy in the
413 for (int i= 0; i < argc -1; ++i)
416 lyxerr << "LyX: Failed to start ispell!" << endl;
420 /* Parent process: Read ispells identification message */
421 // Hmm...what are we using this id msg for? Nothing? (Lgb)
422 // Actually I used it to tell if it's truly Ispell or if it's
423 // aspell -- (kevinatk@home.com)
429 FD_SET(pipeout[0], &infds);
430 tv.tv_sec = 15; // fifteen second timeout. Probably too much,
431 // but it can't really hurt.
434 // Configure provides us with macros which are supposed to do
435 // the right typecast.
436 retval = select(SELECT_TYPE_ARG1 (pipeout[0]+1),
437 SELECT_TYPE_ARG234 (&infds),
440 SELECT_TYPE_ARG5 (&tv));
443 // Ok, do the reading. We don't have to FD_ISSET since
444 // there is only one fd in infds.
445 fgets(buf, 2048, in);
447 // determine if the spell checker is really Aspell
448 if (strstr(buf, "Aspell"))
449 actual_spell_checker = ASC_ASPELL;
451 actual_spell_checker = ASC_ISPELL;
453 fputs("!\n", out); // Set terse mode (silently accept correct words)
456 } else if (retval == 0) {
457 // timeout. Give nice message to user.
458 lyxerr << "Ispell read timed out, what now?" << endl;
459 // This probably works but could need some thought
461 close(pipeout[0]); close(pipeout[1]);
462 close(pipein[0]); close(pipein[1]);
465 // Select returned error
466 lyxerr << "Select on ispell returned error, what now?" << endl;
473 "The ispell-process has died for some reason. *One* possible reason\n"
474 "could be that you do not have a dictionary file\n"
475 "for the language of this document installed.\n"
476 "Check /usr/lib/ispell or set another\n"
477 "dictionary in the Spellchecker Options menu.";
484 bool sc_still_alive() {
485 return isp_pid != -1;
489 void sc_clean_up_after_error()
494 // Send word to ispell and get reply
496 isp_result * sc_check_word(string const & word)
498 //Please rewrite to use string.
500 fputs(word.c_str(), out);
504 fgets(buf, 1024, in);
506 /* I think we have to check if ispell is still alive here because
507 the signal-handler could have disabled blocking on the fd */
508 if (!sc_still_alive()) return 0;
510 isp_result * result = new isp_result;
513 case '*': // Word found
514 result->flag = ISP_OK;
516 case '+': // Word found through affix removal
517 result->flag = ISP_ROOT;
519 case '-': // Word found through compound formation
520 result->flag = ISP_COMPOUNDWORD;
522 case '\n': // Number or when in terse mode: no problems
523 result->flag = ISP_IGNORE;
525 case '#': // Not found, no near misses and guesses
526 result->flag = ISP_UNKNOWN;
528 case '?': // Not found, and no near misses, but guesses (guesses are ignored)
529 case '&': // Not found, but we have near misses
531 result->flag = ISP_MISSED;
532 char * p = strpbrk(buf, ":");
533 result->str = new char[strlen(p) + 1];
534 result->e = result->str;
535 strcpy(result->str, p);
538 default: // This shouldn't happend, but you know Murphy
539 result->flag = ISP_UNKNOWN;
543 if (result->flag!= ISP_IGNORE) {
544 while (*buf!= '\n') fgets(buf, 255, in); /* wait for ispell to finish */
551 void close_spell_checker()
553 // Note: If you decide to optimize this out when it is not
554 // needed please note that when Aspell is used this command
555 // is also needed to save the replacement dictionary.
556 // -- Kevin Atkinson (kevinatk@home.com)
558 fputs("#\n", out); // Save personal dictionary
566 void sc_insert_word(string const & word)
568 fputc('*', out); // Insert word in personal dictionary
569 fputs(word.c_str(), out);
575 void sc_accept_word(string const & word)
577 fputc('@', out); // Accept in this session
578 fputs(word.c_str(), out);
583 void sc_store_replacement(string const & mis, string const & cor) {
584 if(actual_spell_checker == ASC_ASPELL) {
586 fputs(mis.c_str(), out);
588 fputs(cor.c_str(), out);
595 PspellCanHaveError * spell_error_object;
598 void init_spell_checker(BufferParams const &, string const & lang)
600 PspellConfig * config = new_pspell_config();
602 (void)split(lang, code, '_');
603 config->replace("language-tag", code.c_str());
604 spell_error_object = new_pspell_manager(config);
605 if (pspell_error_number(spell_error_object) != 0) {
606 spell_error = pspell_error_message(spell_error_object);
609 sc = to_pspell_manager(spell_error_object);
610 spell_error_object = 0;
615 bool sc_still_alive() {
620 void sc_clean_up_after_error()
622 delete_pspell_can_have_error(spell_error_object);
627 // Send word to ispell and get reply
629 isp_result * sc_check_word(string const & word)
631 isp_result * result = new isp_result;
632 int word_ok = pspell_manager_check(sc, word.c_str());
633 Assert(word_ok != -1);
636 result->flag = ISP_OK;
638 PspellWordList const * sugs =
639 pspell_manager_suggest(sc, word.c_str());
641 result->els = pspell_word_list_elements(sugs);
642 if (pspell_word_list_empty(sugs))
643 result->flag = ISP_UNKNOWN;
645 result->flag = ISP_MISSED;
652 void close_spell_checker()
654 pspell_manager_save_all_word_lists(sc);
659 void sc_insert_word(string const & word)
661 pspell_manager_add_to_personal(sc, word.c_str());
666 void sc_accept_word(string const & word)
668 pspell_manager_add_to_session(sc, word.c_str());
673 void sc_store_replacement(string const & mis, string const & cor)
675 pspell_manager_store_replacement(sc, mis.c_str(), cor.c_str());
680 void ShowSpellChecker(BufferView * bv)
685 // Exit if we don't have a document open
686 if (!bv->available())
689 if (fd_form_spell_check == 0) {
690 fd_form_spell_check = create_form_form_spell_check();
691 // Make sure pressing the close box does not kill LyX. (RvdK)
692 fl_set_form_atclose(fd_form_spell_check->form_spell_check,
693 CancelCloseBoxCB, 0);
697 fl_set_slider_value(fd_form_spell_check->slider, 0);
698 fl_set_slider_bounds(fd_form_spell_check->slider, 0, 100);
699 fl_set_object_label(fd_form_spell_check->text, "");
700 fl_set_input(fd_form_spell_check->input, "");
701 fl_clear_browser(fd_form_spell_check->browser);
704 if (fd_form_spell_check->form_spell_check->visible) {
705 fl_raise_form(fd_form_spell_check->form_spell_check);
707 fl_show_form(fd_form_spell_check->form_spell_check,
708 FL_PLACE_MOUSE, FL_FULLBORDER,
711 fl_deactivate_object(fd_form_spell_check->slider);
713 // deactivate insert, accept, replace, and stop
714 fl_deactivate_object(fd_form_spell_check->insert);
715 fl_deactivate_object(fd_form_spell_check->accept);
716 fl_deactivate_object(fd_form_spell_check->ignore);
717 fl_deactivate_object(fd_form_spell_check->replace);
718 fl_deactivate_object(fd_form_spell_check->stop);
719 fl_deactivate_object(fd_form_spell_check->input);
720 fl_deactivate_object(fd_form_spell_check->browser);
721 fl_set_object_lcol(fd_form_spell_check->insert, FL_INACTIVE);
722 fl_set_object_lcol(fd_form_spell_check->accept, FL_INACTIVE);
723 fl_set_object_lcol(fd_form_spell_check->ignore, FL_INACTIVE);
724 fl_set_object_lcol(fd_form_spell_check->replace, FL_INACTIVE);
725 fl_set_object_lcol(fd_form_spell_check->stop, FL_INACTIVE);
726 fl_set_object_lcol(fd_form_spell_check->input, FL_INACTIVE);
727 fl_set_object_lcol(fd_form_spell_check->browser, FL_INACTIVE);
731 if (obj == fd_form_spell_check->options){
732 SpellCheckerOptions();
734 if (obj == fd_form_spell_check->start){
735 // activate insert, accept, and stop
736 fl_activate_object(fd_form_spell_check->insert);
737 fl_activate_object(fd_form_spell_check->accept);
738 fl_activate_object(fd_form_spell_check->ignore);
739 fl_activate_object(fd_form_spell_check->stop);
740 fl_activate_object(fd_form_spell_check->input);
741 fl_activate_object(fd_form_spell_check->browser);
742 fl_set_object_lcol(fd_form_spell_check->insert, FL_BLACK);
743 fl_set_object_lcol(fd_form_spell_check->accept, FL_BLACK);
744 fl_set_object_lcol(fd_form_spell_check->ignore, FL_BLACK);
745 fl_set_object_lcol(fd_form_spell_check->stop, FL_BLACK);
746 fl_set_object_lcol(fd_form_spell_check->input, FL_BLACK);
747 fl_set_object_lcol(fd_form_spell_check->browser, FL_BLACK);
748 // activate replace only if the file is not read-only
749 if (!bv->buffer()->isReadonly()) {
750 fl_activate_object(fd_form_spell_check->replace);
751 fl_set_object_lcol(fd_form_spell_check->replace, FL_BLACK);
754 // deactivate options and start
755 fl_deactivate_object(fd_form_spell_check->options);
756 fl_deactivate_object(fd_form_spell_check->start);
757 fl_set_object_lcol(fd_form_spell_check->options, FL_INACTIVE);
758 fl_set_object_lcol(fd_form_spell_check->start, FL_INACTIVE);
760 ret = RunSpellChecker(bv);
762 // deactivate insert, accept, replace, and stop
763 fl_deactivate_object(fd_form_spell_check->insert);
764 fl_deactivate_object(fd_form_spell_check->accept);
765 fl_deactivate_object(fd_form_spell_check->ignore);
766 fl_deactivate_object(fd_form_spell_check->replace);
767 fl_deactivate_object(fd_form_spell_check->stop);
768 fl_deactivate_object(fd_form_spell_check->input);
769 fl_deactivate_object(fd_form_spell_check->browser);
770 fl_set_object_lcol(fd_form_spell_check->insert, FL_INACTIVE);
771 fl_set_object_lcol(fd_form_spell_check->accept, FL_INACTIVE);
772 fl_set_object_lcol(fd_form_spell_check->ignore, FL_INACTIVE);
773 fl_set_object_lcol(fd_form_spell_check->replace, FL_INACTIVE);
774 fl_set_object_lcol(fd_form_spell_check->stop, FL_INACTIVE);
775 fl_set_object_lcol(fd_form_spell_check->input, FL_INACTIVE);
776 fl_set_object_lcol(fd_form_spell_check->browser, FL_INACTIVE);
778 // activate options and start
779 fl_activate_object(fd_form_spell_check->options);
780 fl_activate_object(fd_form_spell_check->start);
781 fl_set_object_lcol(fd_form_spell_check->options, FL_BLACK);
782 fl_set_object_lcol(fd_form_spell_check->start, FL_BLACK);
784 // if RunSpellChecker returns false quit spellchecker
787 if (obj == fd_form_spell_check->done) break;
789 fl_hide_form(fd_form_spell_check->form_spell_check);
790 bv->endOfSpellCheck();
795 // Perform a spell session
797 bool RunSpellChecker(BufferView * bv)
804 string tmp = (lyxrc.isp_use_alt_lang) ?
805 lyxrc.isp_alt_lang : bv->buffer()->params.language_info->code();
807 string tmp = (lyxrc.isp_use_alt_lang) ?
808 lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
810 #warning This is not good we should find a way to identify a rtl-language in a more general way. Please have a look Dekel! (Jug)
811 // For now I'll change this to a bit more general solution but
812 // Please comment on this if you don't like it. We probaly need
813 // anoter flag something like lyxrc.isp_use_alt_lang_rtl (true/false)!
815 if (lyxrc.isp_use_alt_lang)
816 rtl = (tmp == "hebrew" || tmp == "arabic");
818 rtl = bv->buffer()->params.language_info->RightToLeft();
820 int oldval = 0; /* used for updating slider only when needed */
823 /* create ispell process */
824 init_spell_checker(bv->buffer()->params, tmp);
826 if (spell_error != 0) {
827 fl_show_message(_(spell_error), "", "");
828 sc_clean_up_after_error();
832 unsigned int word_count = 0;
835 string const word = bv->nextWord(newval);
836 if (word.empty()) break;
839 // Update slider if and only if value has changed
840 newvalue = int(100.0*newval);
841 if(newvalue!= oldval) {
843 fl_set_slider_value(fd_form_spell_check->slider, oldval);
846 if (word_count%1000 == 0) {
847 obj = fl_check_forms();
848 if (obj == fd_form_spell_check->stop) {
849 close_spell_checker();
852 if (obj == fd_form_spell_check->done) {
853 close_spell_checker();
858 result = sc_check_word(word);
859 if (!sc_still_alive()) {
864 switch (result->flag) {
868 bv->selectLastWord();
871 reverse(tmp.begin(),tmp.end());
872 fl_set_object_label(fd_form_spell_check->text, tmp.c_str());
874 fl_set_object_label(fd_form_spell_check->text, word.c_str());
875 fl_set_input(fd_form_spell_check->input, word.c_str());
876 fl_clear_browser(fd_form_spell_check->browser);
878 while ((w = result->next_miss()) != 0) {
881 reverse(tmp.begin(),tmp.end());
882 fl_add_browser_line(fd_form_spell_check->browser, tmp.c_str());
884 fl_add_browser_line(fd_form_spell_check->browser, w);
890 if (obj == fd_form_spell_check->insert) {
891 sc_insert_word(word);
894 if (obj == fd_form_spell_check->accept) {
895 sc_accept_word(word);
898 if (obj == fd_form_spell_check->ignore) {
901 if (obj == fd_form_spell_check->replace ||
902 obj == fd_form_spell_check->input) {
903 sc_store_replacement(word, fl_get_input(fd_form_spell_check->input));
904 bv->replaceWord(fl_get_input(fd_form_spell_check->input));
907 if (obj == fd_form_spell_check->browser) {
908 // implements double click in the browser window.
909 // sent to lyx@via by Mark Burton <mark@cbl.leeds.ac.uk>
911 fl_get_browser(fd_form_spell_check->browser)) {
912 sc_store_replacement(word, fl_get_input(fd_form_spell_check->input));
913 bv->replaceWord(fl_get_input(fd_form_spell_check->input));
916 clickline = fl_get_browser(fd_form_spell_check->browser);
918 /// fl_set_input(fd_form_spell_check->input, result->misses[clickline-1]); ?
920 string tmp = fl_get_browser_line(fd_form_spell_check->browser,
922 reverse(tmp.begin(),tmp.end());
923 fl_set_input(fd_form_spell_check->input, tmp.c_str());
925 fl_set_input(fd_form_spell_check->input,
926 fl_get_browser_line(fd_form_spell_check->browser,
929 if (obj == fd_form_spell_check->stop) {
931 close_spell_checker();
935 if (obj == fd_form_spell_check->done) {
937 close_spell_checker();
947 if(sc_still_alive()) {
948 close_spell_checker();
949 string word_msg(tostr(word_count));
950 if (word_count != 1) {
951 word_msg += _(" words checked.");
953 word_msg += _(" word checked.");
955 fl_show_message("", _("Spellchecking completed!"),
959 fl_show_message(_("The spell checker has died for some reason.\n"
960 "Maybe it has been killed."), "", "");
961 sc_clean_up_after_error();
969 void sigchldhandler(pid_t pid, int * status)
972 if (pid == isp_pid) {
974 fcntl(isp_fd, F_SETFL, O_NONBLOCK); /* set the file descriptor
975 to nonblocking so we can
978 sigchldchecker(pid, status);
983 void sigchldhandler(pid_t, int *)