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) {
585 ::fputs("$$ra ", out);
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 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 #warning Why isnt word_ok a bool? (Lgb)
633 int word_ok = pspell_manager_check(sc, word.c_str());
634 Assert(word_ok != -1);
637 result->flag = ISP_OK;
639 PspellWordList const * sugs =
640 pspell_manager_suggest(sc, word.c_str());
642 result->els = pspell_word_list_elements(sugs);
643 if (pspell_word_list_empty(sugs))
644 result->flag = ISP_UNKNOWN;
646 result->flag = ISP_MISSED;
653 void close_spell_checker()
655 pspell_manager_save_all_word_lists(sc);
660 void sc_insert_word(string const & word)
662 pspell_manager_add_to_personal(sc, word.c_str());
667 void sc_accept_word(string const & word)
669 pspell_manager_add_to_session(sc, word.c_str());
674 void sc_store_replacement(string const & mis, string const & cor)
676 pspell_manager_store_replacement(sc, mis.c_str(), cor.c_str());
681 void ShowSpellChecker(BufferView * bv)
686 // Exit if we don't have a document open
687 if (!bv->available())
690 if (fd_form_spell_check == 0) {
691 fd_form_spell_check = create_form_form_spell_check();
692 // Make sure pressing the close box does not kill LyX. (RvdK)
693 fl_set_form_atclose(fd_form_spell_check->form_spell_check,
694 CancelCloseBoxCB, 0);
698 fl_set_slider_value(fd_form_spell_check->slider, 0);
699 fl_set_slider_bounds(fd_form_spell_check->slider, 0, 100);
700 fl_set_object_label(fd_form_spell_check->text, "");
701 fl_set_input(fd_form_spell_check->input, "");
702 fl_clear_browser(fd_form_spell_check->browser);
705 if (fd_form_spell_check->form_spell_check->visible) {
706 fl_raise_form(fd_form_spell_check->form_spell_check);
708 fl_show_form(fd_form_spell_check->form_spell_check,
709 FL_PLACE_MOUSE, FL_FULLBORDER,
712 fl_deactivate_object(fd_form_spell_check->slider);
714 // deactivate insert, accept, replace, and stop
715 fl_deactivate_object(fd_form_spell_check->insert);
716 fl_deactivate_object(fd_form_spell_check->accept);
717 fl_deactivate_object(fd_form_spell_check->ignore);
718 fl_deactivate_object(fd_form_spell_check->replace);
719 fl_deactivate_object(fd_form_spell_check->stop);
720 fl_deactivate_object(fd_form_spell_check->input);
721 fl_deactivate_object(fd_form_spell_check->browser);
722 fl_set_object_lcol(fd_form_spell_check->insert, FL_INACTIVE);
723 fl_set_object_lcol(fd_form_spell_check->accept, FL_INACTIVE);
724 fl_set_object_lcol(fd_form_spell_check->ignore, FL_INACTIVE);
725 fl_set_object_lcol(fd_form_spell_check->replace, FL_INACTIVE);
726 fl_set_object_lcol(fd_form_spell_check->stop, FL_INACTIVE);
727 fl_set_object_lcol(fd_form_spell_check->input, FL_INACTIVE);
728 fl_set_object_lcol(fd_form_spell_check->browser, FL_INACTIVE);
732 if (obj == fd_form_spell_check->options) {
733 SpellCheckerOptions();
735 if (obj == fd_form_spell_check->start) {
736 // activate insert, accept, and stop
737 fl_activate_object(fd_form_spell_check->insert);
738 fl_activate_object(fd_form_spell_check->accept);
739 fl_activate_object(fd_form_spell_check->ignore);
740 fl_activate_object(fd_form_spell_check->stop);
741 fl_activate_object(fd_form_spell_check->input);
742 fl_activate_object(fd_form_spell_check->browser);
743 fl_set_object_lcol(fd_form_spell_check->insert, FL_BLACK);
744 fl_set_object_lcol(fd_form_spell_check->accept, FL_BLACK);
745 fl_set_object_lcol(fd_form_spell_check->ignore, FL_BLACK);
746 fl_set_object_lcol(fd_form_spell_check->stop, FL_BLACK);
747 fl_set_object_lcol(fd_form_spell_check->input, FL_BLACK);
748 fl_set_object_lcol(fd_form_spell_check->browser, FL_BLACK);
749 // activate replace only if the file is not read-only
750 if (!bv->buffer()->isReadonly()) {
751 fl_activate_object(fd_form_spell_check->replace);
752 fl_set_object_lcol(fd_form_spell_check->replace, FL_BLACK);
755 // deactivate options and start
756 fl_deactivate_object(fd_form_spell_check->options);
757 fl_deactivate_object(fd_form_spell_check->start);
758 fl_set_object_lcol(fd_form_spell_check->options, FL_INACTIVE);
759 fl_set_object_lcol(fd_form_spell_check->start, FL_INACTIVE);
761 ret = RunSpellChecker(bv);
763 // deactivate insert, accept, replace, and stop
764 fl_deactivate_object(fd_form_spell_check->insert);
765 fl_deactivate_object(fd_form_spell_check->accept);
766 fl_deactivate_object(fd_form_spell_check->ignore);
767 fl_deactivate_object(fd_form_spell_check->replace);
768 fl_deactivate_object(fd_form_spell_check->stop);
769 fl_deactivate_object(fd_form_spell_check->input);
770 fl_deactivate_object(fd_form_spell_check->browser);
771 fl_set_object_lcol(fd_form_spell_check->insert, FL_INACTIVE);
772 fl_set_object_lcol(fd_form_spell_check->accept, FL_INACTIVE);
773 fl_set_object_lcol(fd_form_spell_check->ignore, FL_INACTIVE);
774 fl_set_object_lcol(fd_form_spell_check->replace, FL_INACTIVE);
775 fl_set_object_lcol(fd_form_spell_check->stop, FL_INACTIVE);
776 fl_set_object_lcol(fd_form_spell_check->input, FL_INACTIVE);
777 fl_set_object_lcol(fd_form_spell_check->browser, FL_INACTIVE);
779 // activate options and start
780 fl_activate_object(fd_form_spell_check->options);
781 fl_activate_object(fd_form_spell_check->start);
782 fl_set_object_lcol(fd_form_spell_check->options, FL_BLACK);
783 fl_set_object_lcol(fd_form_spell_check->start, FL_BLACK);
785 // if RunSpellChecker returns false quit spellchecker
788 if (obj == fd_form_spell_check->done) break;
790 fl_hide_form(fd_form_spell_check->form_spell_check);
791 bv->endOfSpellCheck();
796 // Perform a spell session
798 bool RunSpellChecker(BufferView * bv)
805 string tmp = (lyxrc.isp_use_alt_lang) ?
806 lyxrc.isp_alt_lang : bv->buffer()->params.language_info->code();
808 string tmp = (lyxrc.isp_use_alt_lang) ?
809 lyxrc.isp_alt_lang : bv->buffer()->GetLanguage();
811 #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)
812 // For now I'll change this to a bit more general solution but
813 // Please comment on this if you don't like it. We probaly need
814 // anoter flag something like lyxrc.isp_use_alt_lang_rtl (true/false)!
816 if (lyxrc.isp_use_alt_lang)
817 rtl = (tmp == "hebrew" || tmp == "arabic");
819 rtl = bv->buffer()->params.language_info->RightToLeft();
821 int oldval = 0; /* used for updating slider only when needed */
824 /* create ispell process */
825 init_spell_checker(bv->buffer()->params, tmp);
827 if (spell_error != 0) {
828 fl_show_message(_(spell_error), "", "");
829 sc_clean_up_after_error();
833 unsigned int word_count = 0;
836 string const word = bv->nextWord(newval);
837 if (word.empty()) break;
840 // Update slider if and only if value has changed
841 newvalue = int(100.0*newval);
842 if(newvalue!= oldval) {
844 fl_set_slider_value(fd_form_spell_check->slider, oldval);
847 if (word_count%1000 == 0) {
848 obj = fl_check_forms();
849 if (obj == fd_form_spell_check->stop) {
850 close_spell_checker();
853 if (obj == fd_form_spell_check->done) {
854 close_spell_checker();
859 result = sc_check_word(word);
860 if (!sc_still_alive()) {
865 switch (result->flag) {
869 bv->selectLastWord();
872 reverse(tmp.begin(),tmp.end());
873 fl_set_object_label(fd_form_spell_check->text, tmp.c_str());
875 fl_set_object_label(fd_form_spell_check->text, word.c_str());
876 fl_set_input(fd_form_spell_check->input, word.c_str());
877 fl_clear_browser(fd_form_spell_check->browser);
879 while ((w = result->next_miss()) != 0) {
882 reverse(tmp.begin(),tmp.end());
883 fl_add_browser_line(fd_form_spell_check->browser, tmp.c_str());
885 fl_add_browser_line(fd_form_spell_check->browser, w);
891 if (obj == fd_form_spell_check->insert) {
892 sc_insert_word(word);
895 if (obj == fd_form_spell_check->accept) {
896 sc_accept_word(word);
899 if (obj == fd_form_spell_check->ignore) {
902 if (obj == fd_form_spell_check->replace ||
903 obj == fd_form_spell_check->input) {
904 sc_store_replacement(word, fl_get_input(fd_form_spell_check->input));
905 bv->replaceWord(fl_get_input(fd_form_spell_check->input));
908 if (obj == fd_form_spell_check->browser) {
909 // implements double click in the browser window.
910 // sent to lyx@via by Mark Burton <mark@cbl.leeds.ac.uk>
912 fl_get_browser(fd_form_spell_check->browser)) {
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 clickline = fl_get_browser(fd_form_spell_check->browser);
919 /// fl_set_input(fd_form_spell_check->input, result->misses[clickline-1]); ?
921 string tmp = fl_get_browser_line(fd_form_spell_check->browser,
923 reverse(tmp.begin(),tmp.end());
924 fl_set_input(fd_form_spell_check->input, tmp.c_str());
926 fl_set_input(fd_form_spell_check->input,
927 fl_get_browser_line(fd_form_spell_check->browser,
930 if (obj == fd_form_spell_check->stop) {
932 close_spell_checker();
936 if (obj == fd_form_spell_check->done) {
938 close_spell_checker();
948 if(sc_still_alive()) {
949 close_spell_checker();
950 string word_msg(tostr(word_count));
951 if (word_count != 1) {
952 word_msg += _(" words checked.");
954 word_msg += _(" word checked.");
956 fl_show_message("", _("Spellchecking completed!"),
960 fl_show_message(_("The spell checker has died for some reason.\n"
961 "Maybe it has been killed."), "", "");
962 sc_clean_up_after_error();
970 void sigchldhandler(pid_t pid, int * status)
973 if (pid == isp_pid) {
975 fcntl(isp_fd, F_SETFL, O_NONBLOCK); /* set the file descriptor
976 to nonblocking so we can
979 sigchldchecker(pid, status);
984 void sigchldhandler(pid_t, int *)