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().
43 // BUT we cannot include both string.h and strings.h on Irix 6.5 :(
48 #include <sys/select.h>
55 #include "spellchecker.h"
59 #include "BufferView.h"
61 #include "lyx_gui_misc.h"
63 #include "support/lstrings.h"
66 #include "support/lstrings.h"
69 #define USE_ORIGINAL_MANAGER_FUNCS 1
70 # include <pspell/pspell.h>
78 // Spellchecker status
88 bool RunSpellChecker(BufferView * bv);
93 FILE * out; /* streams to communicate with ispell */
94 pid_t isp_pid = -1; // pid for the `ispell' process. Also used (RO) in
97 // the true spell checker program being used
98 enum ActualSpellChecker {ASC_ISPELL, ASC_ASPELL};
99 ActualSpellChecker actual_spell_checker;
112 // Non-static so that it can be redrawn if the xforms colors are re-mapped
113 FD_form_spell_options *fd_form_spell_options = 0;
114 FD_form_spell_check *fd_form_spell_check = 0;
116 void sigchldhandler(pid_t pid, int *status);
118 extern void sigchldchecker(pid_t pid, int *status);
127 const char * next_miss();
137 const char * isp_result::next_miss() {
138 if (str == 0 || *(e+1) == '\0') return 0;
140 e = strpbrk(b, ",\n");
149 PspellStringEmulation * els;
151 const char * next_miss();
157 delete_pspell_string_emulation(els);
161 const char * isp_result::next_miss()
163 return pspell_string_emulation_next(els);
168 const char * spell_error;
171 /***** Spellchecker options *****/
173 // Rewritten to use ordinary LyX xforms loop and OK, Apply and Cancel set,
174 // now also string. Amazing, eh? (Asger)
176 // Set (sane) values in form to current spellchecker options
177 void SpellOptionsUpdate()
179 // Alternate language
180 if (lyxrc.isp_alt_lang.empty()) {
181 lyxrc.isp_use_alt_lang = false;
183 fl_set_input(fd_form_spell_options->altlang_input,
184 lyxrc.isp_alt_lang.c_str());
186 if (lyxrc.isp_use_alt_lang) {
187 fl_set_button(fd_form_spell_options->buflang, 0);
188 fl_set_button(fd_form_spell_options->altlang, 1);
190 fl_set_button(fd_form_spell_options->buflang, 1);
191 fl_set_button(fd_form_spell_options->altlang, 0);
194 // Personal dictionary
195 if (lyxrc.isp_pers_dict.empty()) {
196 lyxrc.isp_use_pers_dict = false;
198 fl_set_input(fd_form_spell_options->perdict_input,
199 lyxrc.isp_pers_dict.c_str());
201 fl_set_button(fd_form_spell_options->perdict,
202 lyxrc.isp_use_pers_dict ? 1:0);
205 if (lyxrc.isp_esc_chars.empty()) {
206 lyxrc.isp_use_esc_chars = false;
208 fl_set_input(fd_form_spell_options->esc_chars_input,
209 lyxrc.isp_esc_chars.c_str());
211 fl_set_button(fd_form_spell_options->esc_chars,
212 lyxrc.isp_use_esc_chars ? 1:0);
215 fl_set_button(fd_form_spell_options->compounds,
216 lyxrc.isp_accept_compound ? 1 : 0);
217 fl_set_button(fd_form_spell_options->inpenc,
218 lyxrc.isp_use_input_encoding ? 1 : 0);
221 // Update spellchecker options
222 void SpellOptionsApplyCB(FL_OBJECT *, long)
224 // Build new status from form data
225 lyxrc.isp_use_alt_lang =
226 fl_get_button(fd_form_spell_options->altlang);
227 lyxrc.isp_use_pers_dict =
228 fl_get_button(fd_form_spell_options->perdict);
229 lyxrc.isp_accept_compound =
230 fl_get_button(fd_form_spell_options->compounds);
231 lyxrc.isp_use_esc_chars =
232 fl_get_button(fd_form_spell_options->esc_chars);
233 lyxrc.isp_use_input_encoding =
234 fl_get_button(fd_form_spell_options->inpenc);
236 // Update strings with data from input fields
238 fl_get_input(fd_form_spell_options->altlang_input);
239 lyxrc.isp_pers_dict =
240 fl_get_input(fd_form_spell_options->perdict_input);
241 lyxrc.isp_esc_chars =
242 fl_get_input(fd_form_spell_options->esc_chars_input);
245 SpellOptionsUpdate();
249 void SpellOptionsCancelCB(FL_OBJECT *, long)
251 fl_hide_form(fd_form_spell_options->form_spell_options);
255 void SpellOptionsOKCB(FL_OBJECT * ob, long data)
257 SpellOptionsApplyCB(ob, data);
258 SpellOptionsCancelCB(ob, data);
262 // Show spellchecker options form
263 void SpellCheckerOptions()
265 // Create form if nescessary
266 if (fd_form_spell_options == 0) {
267 fd_form_spell_options = create_form_form_spell_options();
268 // Make sure pressing the close box does not kill LyX. (RvdK)
269 fl_set_form_atclose(fd_form_spell_options->form_spell_options,
270 CancelCloseBoxCB, 0);
273 // Update form to current options
274 SpellOptionsUpdate();
276 // Focus in alternate language field
277 fl_set_focus_object(fd_form_spell_options->form_spell_options,
278 fd_form_spell_options->altlang_input);
281 if (fd_form_spell_options->form_spell_options->visible) {
282 fl_raise_form(fd_form_spell_options->form_spell_options);
284 fl_show_form(fd_form_spell_options->form_spell_options,
285 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
286 _("Spellchecker Options"));
294 /***** Spellchecker *****/
296 // Could also use a clean up. (Asger Alstrup)
298 void init_spell_checker(BufferParams const & params, string const & lang)
300 static char o_buf[BUFSIZ]; // jc: it could be smaller
301 int pipein[2], pipeout[2];
307 if (pipe(pipein) == -1 || pipe(pipeout) == -1) {
308 lyxerr << "LyX: Can't create pipe for spellchecker!" << endl;
312 if ((out = fdopen(pipein[1], "w")) == 0) {
313 lyxerr << "LyX: Can't create stream for pipe for spellchecker!"
318 if ((in = fdopen(pipeout[0], "r")) == 0) {
319 lyxerr <<"LyX: Can't create stream for pipe for spellchecker!"
324 setvbuf(out, o_buf, _IOLBF, BUFSIZ);
331 lyxerr << "LyX: Can't create child process for spellchecker!"
338 dup2(pipein[0], STDIN_FILENO);
339 dup2(pipeout[1], STDOUT_FILENO);
346 char * tmp = new char[lyxrc.isp_command.length() + 1];
347 lyxrc.isp_command.copy(tmp, lyxrc.isp_command.length());
348 tmp[lyxrc.isp_command.length()] = '\0';
351 string("-a").copy(tmp, 2); tmp[2] = '\0'; // pipe mode
354 if (lang != "default") {
356 string("-d").copy(tmp, 2); tmp[2] = '\0'; // Dictionary file
358 tmp = new char[lang.length() + 1];
359 lang.copy(tmp, lang.length()); tmp[lang.length()] = '\0';
363 if (lyxrc.isp_accept_compound) {
364 // Consider run-together words as legal compounds
366 string("-C").copy(tmp, 2); tmp[2] = '\0';
369 // Report run-together words with
370 // missing blanks as errors
372 string("-B").copy(tmp, 2); tmp[2] = '\0';
375 if (lyxrc.isp_use_esc_chars) {
376 // Specify additional characters that
377 // can be part of a word
379 string("-w").copy(tmp, 2); tmp[2] = '\0';
381 // Put the escape chars in ""s
382 string tms = "\"" + lyxrc.isp_esc_chars + "\"";
383 tmp = new char[tms.length() + 1];
384 tms.copy(tmp, tms.length()); tmp[tms.length()] = '\0';
387 if (lyxrc.isp_use_pers_dict) {
388 // Specify an alternate personal dictionary
390 string("-p").copy(tmp, 2);
393 tmp = new char[lyxrc.isp_pers_dict.length() + 1];
394 lyxrc.isp_pers_dict.copy(tmp, lyxrc.isp_pers_dict.length());
395 tmp[lyxrc.isp_pers_dict.length()] = '\0';
398 if (lyxrc.isp_use_input_encoding &&
399 params.inputenc != "default") {
400 string enc = (params.inputenc == "auto")
401 ? params.language->encoding()->LatexName()
403 string::size_type n = enc.length();
405 string("-T").copy(tmp, 2); tmp[2] = '\0';
406 argv[argc++] = tmp; // Input encoding
407 tmp = new char[n + 1];
415 execvp(argv[0], const_cast<char * const *>(argv));
417 // free the memory used by string::copy in the
419 for (int i= 0; i < argc -1; ++i)
422 lyxerr << "LyX: Failed to start ispell!" << endl;
426 /* Parent process: Read ispells identification message */
427 // Hmm...what are we using this id msg for? Nothing? (Lgb)
428 // Actually I used it to tell if it's truly Ispell or if it's
429 // aspell -- (kevinatk@home.com)
435 FD_SET(pipeout[0], &infds);
436 tv.tv_sec = 15; // fifteen second timeout. Probably too much,
437 // but it can't really hurt.
440 // Configure provides us with macros which are supposed to do
441 // the right typecast.
442 retval = select(SELECT_TYPE_ARG1 (pipeout[0]+1),
443 SELECT_TYPE_ARG234 (&infds),
446 SELECT_TYPE_ARG5 (&tv));
449 // Ok, do the reading. We don't have to FD_ISSET since
450 // there is only one fd in infds.
451 fgets(buf, 2048, in);
453 // determine if the spell checker is really Aspell
454 if (strstr(buf, "Aspell"))
455 actual_spell_checker = ASC_ASPELL;
457 actual_spell_checker = ASC_ISPELL;
459 fputs("!\n", out); // Set terse mode (silently accept correct words)
462 } else if (retval == 0) {
463 // timeout. Give nice message to user.
464 lyxerr << "Ispell read timed out, what now?" << endl;
465 // This probably works but could need some thought
467 close(pipeout[0]); close(pipeout[1]);
468 close(pipein[0]); close(pipein[1]);
471 // Select returned error
472 lyxerr << "Select on ispell returned error, what now?" << endl;
479 "The ispell-process has died for some reason. *One* possible reason\n"
480 "could be that you do not have a dictionary file\n"
481 "for the language of this document installed.\n"
482 "Check /usr/lib/ispell or set another\n"
483 "dictionary in the Spellchecker Options menu.";
490 bool sc_still_alive() {
491 return isp_pid != -1;
495 void sc_clean_up_after_error()
501 // Send word to ispell and get reply
502 isp_result * sc_check_word(string const & word)
504 //Please rewrite to use string.
506 ::fputs(word.c_str(), out);
510 ::fgets(buf, 1024, in);
512 /* I think we have to check if ispell is still alive here because
513 the signal-handler could have disabled blocking on the fd */
514 if (!sc_still_alive()) return 0;
516 isp_result * result = new isp_result;
519 case '*': // Word found
520 result->flag = ISP_OK;
522 case '+': // Word found through affix removal
523 result->flag = ISP_ROOT;
525 case '-': // Word found through compound formation
526 result->flag = ISP_COMPOUNDWORD;
528 case '\n': // Number or when in terse mode: no problems
529 result->flag = ISP_IGNORE;
531 case '#': // Not found, no near misses and guesses
532 result->flag = ISP_UNKNOWN;
534 case '?': // Not found, and no near misses, but guesses (guesses are ignored)
535 case '&': // Not found, but we have near misses
537 result->flag = ISP_MISSED;
538 char * p = strpbrk(buf, ":");
539 result->str = new char[strlen(p) + 1];
540 result->e = result->str;
541 strcpy(result->str, p);
544 default: // This shouldn't happend, but you know Murphy
545 result->flag = ISP_UNKNOWN;
549 if (result->flag!= ISP_IGNORE) {
550 while (*buf!= '\n') fgets(buf, 255, in); /* wait for ispell to finish */
557 void close_spell_checker()
559 // Note: If you decide to optimize this out when it is not
560 // needed please note that when Aspell is used this command
561 // is also needed to save the replacement dictionary.
562 // -- Kevin Atkinson (kevinatk@home.com)
564 fputs("#\n", out); // Save personal dictionary
572 void sc_insert_word(string const & word)
574 ::fputc('*', out); // Insert word in personal dictionary
575 ::fputs(word.c_str(), out);
581 void sc_accept_word(string const & word)
583 ::fputc('@', out); // Accept in this session
584 ::fputs(word.c_str(), out);
590 void sc_store_replacement(string const & mis, string const & cor) {
591 if (actual_spell_checker == ASC_ASPELL) {
592 ::fputs("$$ra ", out);
593 ::fputs(mis.c_str(), out);
595 ::fputs(cor.c_str(), out);
602 PspellCanHaveError * spell_error_object;
604 void init_spell_checker(BufferParams const &, string const & lang)
606 PspellConfig * config = new_pspell_config();
608 split(lang, code, '_');
609 config->replace("language-tag", code.c_str());
610 spell_error_object = new_pspell_manager(config);
611 if (pspell_error_number(spell_error_object) != 0) {
612 spell_error = pspell_error_message(spell_error_object);
615 sc = to_pspell_manager(spell_error_object);
616 spell_error_object = 0;
621 bool sc_still_alive() {
626 void sc_clean_up_after_error()
628 delete_pspell_can_have_error(spell_error_object);
633 // Send word to pspell and get reply
634 isp_result * sc_check_word(string const & word)
636 isp_result * result = new isp_result;
638 #warning Why isnt word_ok a bool? (Lgb)
640 int word_ok = pspell_manager_check(sc, word.c_str());
641 lyx::Assert(word_ok != -1);
644 result->flag = ISP_OK;
646 PspellWordList const * sugs =
647 pspell_manager_suggest(sc, word.c_str());
648 lyx::Assert(sugs != 0);
649 result->els = pspell_word_list_elements(sugs);
650 if (pspell_word_list_empty(sugs))
651 result->flag = ISP_UNKNOWN;
653 result->flag = ISP_MISSED;
660 void close_spell_checker()
662 pspell_manager_save_all_word_lists(sc);
667 void sc_insert_word(string const & word)
669 pspell_manager_add_to_personal(sc, word.c_str());
674 void sc_accept_word(string const & word)
676 pspell_manager_add_to_session(sc, word.c_str());
681 void sc_store_replacement(string const & mis, string const & cor)
683 pspell_manager_store_replacement(sc, mis.c_str(), cor.c_str());
691 void ShowSpellChecker(BufferView * bv)
696 // Exit if we don't have a document open
697 if (!bv->available())
700 if (fd_form_spell_check == 0) {
701 fd_form_spell_check = create_form_form_spell_check();
702 // Make sure pressing the close box does not kill LyX. (RvdK)
703 fl_set_form_atclose(fd_form_spell_check->form_spell_check,
704 CancelCloseBoxCB, 0);
708 fl_set_slider_value(fd_form_spell_check->slider, 0);
709 fl_set_slider_bounds(fd_form_spell_check->slider, 0, 100);
710 fl_set_object_label(fd_form_spell_check->text, "");
711 fl_set_input(fd_form_spell_check->input, "");
712 fl_clear_browser(fd_form_spell_check->browser);
715 if (fd_form_spell_check->form_spell_check->visible) {
716 fl_raise_form(fd_form_spell_check->form_spell_check);
718 fl_show_form(fd_form_spell_check->form_spell_check,
719 FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
722 fl_deactivate_object(fd_form_spell_check->slider);
724 // deactivate insert, accept, replace, and stop
725 fl_deactivate_object(fd_form_spell_check->insert);
726 fl_deactivate_object(fd_form_spell_check->accept);
727 fl_deactivate_object(fd_form_spell_check->ignore);
728 fl_deactivate_object(fd_form_spell_check->replace);
729 fl_deactivate_object(fd_form_spell_check->stop);
730 fl_deactivate_object(fd_form_spell_check->input);
731 fl_deactivate_object(fd_form_spell_check->browser);
732 fl_set_object_lcol(fd_form_spell_check->insert, FL_INACTIVE);
733 fl_set_object_lcol(fd_form_spell_check->accept, FL_INACTIVE);
734 fl_set_object_lcol(fd_form_spell_check->ignore, FL_INACTIVE);
735 fl_set_object_lcol(fd_form_spell_check->replace, FL_INACTIVE);
736 fl_set_object_lcol(fd_form_spell_check->stop, FL_INACTIVE);
737 fl_set_object_lcol(fd_form_spell_check->input, FL_INACTIVE);
738 fl_set_object_lcol(fd_form_spell_check->browser, FL_INACTIVE);
742 if (obj == fd_form_spell_check->options) {
743 SpellCheckerOptions();
745 if (obj == fd_form_spell_check->start) {
746 // activate insert, accept, and stop
747 fl_activate_object(fd_form_spell_check->insert);
748 fl_activate_object(fd_form_spell_check->accept);
749 fl_activate_object(fd_form_spell_check->ignore);
750 fl_activate_object(fd_form_spell_check->stop);
751 fl_activate_object(fd_form_spell_check->input);
752 fl_activate_object(fd_form_spell_check->browser);
753 fl_set_object_lcol(fd_form_spell_check->insert, FL_BLACK);
754 fl_set_object_lcol(fd_form_spell_check->accept, FL_BLACK);
755 fl_set_object_lcol(fd_form_spell_check->ignore, FL_BLACK);
756 fl_set_object_lcol(fd_form_spell_check->stop, FL_BLACK);
757 fl_set_object_lcol(fd_form_spell_check->input, FL_BLACK);
758 fl_set_object_lcol(fd_form_spell_check->browser, FL_BLACK);
759 // activate replace only if the file is not read-only
760 if (!bv->buffer()->isReadonly()) {
761 fl_activate_object(fd_form_spell_check->replace);
762 fl_set_object_lcol(fd_form_spell_check->replace, FL_BLACK);
765 // deactivate options and start
766 fl_deactivate_object(fd_form_spell_check->options);
767 fl_deactivate_object(fd_form_spell_check->start);
768 fl_set_object_lcol(fd_form_spell_check->options, FL_INACTIVE);
769 fl_set_object_lcol(fd_form_spell_check->start, FL_INACTIVE);
771 ret = RunSpellChecker(bv);
773 // deactivate insert, accept, replace, and stop
774 fl_deactivate_object(fd_form_spell_check->insert);
775 fl_deactivate_object(fd_form_spell_check->accept);
776 fl_deactivate_object(fd_form_spell_check->ignore);
777 fl_deactivate_object(fd_form_spell_check->replace);
778 fl_deactivate_object(fd_form_spell_check->stop);
779 fl_deactivate_object(fd_form_spell_check->input);
780 fl_deactivate_object(fd_form_spell_check->browser);
781 fl_set_object_lcol(fd_form_spell_check->insert, FL_INACTIVE);
782 fl_set_object_lcol(fd_form_spell_check->accept, FL_INACTIVE);
783 fl_set_object_lcol(fd_form_spell_check->ignore, FL_INACTIVE);
784 fl_set_object_lcol(fd_form_spell_check->replace, FL_INACTIVE);
785 fl_set_object_lcol(fd_form_spell_check->stop, FL_INACTIVE);
786 fl_set_object_lcol(fd_form_spell_check->input, FL_INACTIVE);
787 fl_set_object_lcol(fd_form_spell_check->browser, FL_INACTIVE);
789 // activate options and start
790 fl_activate_object(fd_form_spell_check->options);
791 fl_activate_object(fd_form_spell_check->start);
792 fl_set_object_lcol(fd_form_spell_check->options, FL_BLACK);
793 fl_set_object_lcol(fd_form_spell_check->start, FL_BLACK);
795 // if RunSpellChecker returns false quit spellchecker
798 if (obj == fd_form_spell_check->done) break;
800 fl_hide_form(fd_form_spell_check->form_spell_check);
801 bv->endOfSpellCheck();
806 // Perform a spell session
809 bool RunSpellChecker(BufferView * bv)
816 string tmp = (lyxrc.isp_use_alt_lang) ?
817 lyxrc.isp_alt_lang : bv->buffer()->params.language->code();
819 string tmp = (lyxrc.isp_use_alt_lang) ?
820 lyxrc.isp_alt_lang : bv->buffer()->params.language->lang();
823 if (lyxrc.isp_use_alt_lang) {
824 Language const * lang = languages.getLanguage(tmp);
826 rtl = lang->RightToLeft();
828 rtl = bv->buffer()->params.language->RightToLeft();
830 int oldval = 0; /* used for updating slider only when needed */
833 /* create ispell process */
834 init_spell_checker(bv->buffer()->params, tmp);
836 if (spell_error != 0) {
837 fl_show_message(_(spell_error), "", "");
838 sc_clean_up_after_error();
842 unsigned int word_count = 0;
845 string const word = bv->nextWord(newval);
846 if (word.empty()) break;
849 // Update slider if and only if value has changed
850 newvalue = int(100.0*newval);
851 if (newvalue!= oldval) {
853 fl_set_slider_value(fd_form_spell_check->slider, oldval);
856 if (word_count%1000 == 0) {
857 obj = fl_check_forms();
858 if (obj == fd_form_spell_check->stop) {
859 close_spell_checker();
862 if (obj == fd_form_spell_check->done) {
863 close_spell_checker();
868 result = sc_check_word(word);
869 if (!sc_still_alive()) {
874 switch (result->flag) {
878 bv->selectLastWord();
881 reverse(tmp.begin(),tmp.end());
882 fl_set_object_label(fd_form_spell_check->text, tmp.c_str());
884 fl_set_object_label(fd_form_spell_check->text, word.c_str());
885 fl_set_input(fd_form_spell_check->input, word.c_str());
886 fl_clear_browser(fd_form_spell_check->browser);
888 while ((w = result->next_miss()) != 0) {
891 reverse(tmp.begin(),tmp.end());
892 fl_add_browser_line(fd_form_spell_check->browser, tmp.c_str());
894 fl_add_browser_line(fd_form_spell_check->browser, w);
900 if (obj == fd_form_spell_check->insert) {
901 sc_insert_word(word);
904 if (obj == fd_form_spell_check->accept) {
905 sc_accept_word(word);
908 if (obj == fd_form_spell_check->ignore) {
911 if (obj == fd_form_spell_check->replace ||
912 obj == fd_form_spell_check->input) {
913 sc_store_replacement(word, fl_get_input(fd_form_spell_check->input));
914 bv->replaceWord(fl_get_input(fd_form_spell_check->input));
917 if (obj == fd_form_spell_check->browser) {
918 // implements double click in the browser window.
919 // sent to lyx@via by Mark Burton <mark@cbl.leeds.ac.uk>
921 fl_get_browser(fd_form_spell_check->browser)) {
922 sc_store_replacement(word, fl_get_input(fd_form_spell_check->input));
923 bv->replaceWord(fl_get_input(fd_form_spell_check->input));
926 clickline = fl_get_browser(fd_form_spell_check->browser);
928 /// fl_set_input(fd_form_spell_check->input, result->misses[clickline-1]); ?
930 string tmp = fl_get_browser_line(fd_form_spell_check->browser,
932 reverse(tmp.begin(),tmp.end());
933 fl_set_input(fd_form_spell_check->input, tmp.c_str());
935 fl_set_input(fd_form_spell_check->input,
936 fl_get_browser_line(fd_form_spell_check->browser,
939 if (obj == fd_form_spell_check->stop) {
941 close_spell_checker();
945 if (obj == fd_form_spell_check->done) {
947 close_spell_checker();
957 if (sc_still_alive()) {
958 close_spell_checker();
959 string word_msg(tostr(word_count));
960 if (word_count != 1) {
961 word_msg += _(" words checked.");
963 word_msg += _(" word checked.");
965 fl_show_message("", _("Spellchecking completed!"),
969 fl_show_message(_("The spell checker has died for some reason.\n"
970 "Maybe it has been killed."), "", "");
971 sc_clean_up_after_error();
979 #warning should go somewhere more sensible
981 void sigchldhandler(pid_t pid, int * status)
985 if (pid == isp_pid) {
987 fcntl(isp_fd, F_SETFL, O_NONBLOCK); /* set the file descriptor
988 to nonblocking so we can
992 sigchldchecker(pid, status);