610 * silent_error Should error messages be suppressed for dmake?
611 * target The target we are building, for error msgs
612 * command The command we ran, for error msgs
613 * running_pid The pid of the process we are waiting for
614 *
615 * Static variables used:
616 * filter_file The fd for the filter file
617 * filter_file_name The name of the filter file
618 *
619 * Global variables used:
620 * filter_stderr Set if -X is on
621 */
622 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
623 Boolean
624 await(register Boolean ignore_error, register Boolean silent_error, Name target, wchar_t *command, pid_t running_pid, Boolean send_mtool_msgs, XDR *xdrs_p, int job_msg_id)
625 #else
626 Boolean
627 await(register Boolean ignore_error, register Boolean silent_error, Name target, wchar_t *command, pid_t running_pid, Boolean send_mtool_msgs, void *xdrs_p, int job_msg_id)
628 #endif
629 {
630 #ifdef SUN5_0
631 int status;
632 #else
633 #ifndef WEXITSTATUS
634 #define WEXITSTATUS(stat) stat.w_T.w_Retcode
635 #endif
636 #ifndef WTERMSIG
637 #define WTERMSIG(stat) stat.w_T.w_Termsig
638 #endif
639 #ifndef WCOREDUMP
640 #define WCOREDUMP(stat) stat.w_T.w_Coredump
641 #endif
642 #if defined (HP_UX) || defined (linux)
643 int status;
644 #else
645 union wait status;
646 #endif
647 #endif
648 char *buffer;
649 int core_dumped;
650 int exit_status;
651 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
652 Avo_CmdOutput *make_output_msg;
653 #endif
654 FILE *outfp;
655 register pid_t pid;
656 struct stat stat_buff;
657 int termination_signal;
658 char tmp_buf[MAXPATHLEN];
659 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
660 RWCollectable *xdr_msg;
661 #endif
662
663 while ((pid = wait(&status)) != running_pid) {
664 if (pid == -1) {
665 fatal_mksh(catgets(libmksdmsi18n_catd, 1, 98, "wait() failed: %s"), errmsg(errno));
666 }
667 }
668 (void) fflush(stdout);
669 (void) fflush(stderr);
670
671 #if defined(SUN5_0) || defined(HP_UX) || defined(linux)
672 if (status == 0) {
673
674 #ifdef PRINT_EXIT_STATUS
675 warning_mksh(NOCATGETS("I'm in await(), and status is 0."));
676 #endif
677
678 return succeeded;
679 }
680
681 #ifdef PRINT_EXIT_STATUS
682 warning_mksh(NOCATGETS("I'm in await(), and status is *NOT* 0."));
683 #endif
684
685 #else
686 if (status.w_status == 0) {
687 return succeeded;
688 }
689 #endif
690
691 exit_status = WEXITSTATUS(status);
692
693 #ifdef PRINT_EXIT_STATUS
694 warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status);
695 #endif
696
697 termination_signal = WTERMSIG(status);
698 core_dumped = WCOREDUMP(status);
699
700 /*
701 * If the child returned an error, we now try to print a
702 * nice message about it.
703 */
704 SEND_MTOOL_MSG(
705 make_output_msg = new Avo_CmdOutput();
706 (void) sprintf(tmp_buf, "%d", job_msg_id);
707 make_output_msg->appendOutput(AVO_STRDUP(tmp_buf));
708 );
709
710 tmp_buf[0] = (int) nul_char;
711 if (!silent_error) {
712 if (exit_status != 0) {
713 (void) fprintf(stdout,
714 catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"),
715 exit_status);
716 SEND_MTOOL_MSG(
717 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
718 catgets(libmksdmsi18n_catd, 1, 104, "*** Error code %d"),
719 exit_status);
720 );
721 } else {
722 #if ! defined(SUN5_0) && ! defined(HP_UX) && ! defined(linux)
723 if (termination_signal > NSIG) {
724 #endif
725 (void) fprintf(stdout,
726 catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"),
727 termination_signal);
728 SEND_MTOOL_MSG(
729 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
730 catgets(libmksdmsi18n_catd, 1, 106, "*** Signal %d"),
731 termination_signal);
732 );
733 #if ! defined(SUN5_0) && ! defined(HP_UX) && ! defined(linux)
734 } else {
735 (void) fprintf(stdout,
736 "*** %s",
737 sys_siglist[termination_signal]);
738 SEND_MTOOL_MSG(
739 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
740 "*** %s",
741 sys_siglist[termination_signal]);
742 );
743 }
744 #endif
745 if (core_dumped) {
746 (void) fprintf(stdout,
747 catgets(libmksdmsi18n_catd, 1, 107, " - core dumped"));
748 SEND_MTOOL_MSG(
749 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
750 catgets(libmksdmsi18n_catd, 1, 108, " - core dumped"));
751 );
752 }
753 }
754 if (ignore_error) {
755 (void) fprintf(stdout,
756 catgets(libmksdmsi18n_catd, 1, 109, " (ignored)"));
757 SEND_MTOOL_MSG(
758 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
759 catgets(libmksdmsi18n_catd, 1, 110, " (ignored)"));
760 );
761 }
762 (void) fprintf(stdout, "\n");
763 (void) fflush(stdout);
764 SEND_MTOOL_MSG(
|
610 * silent_error Should error messages be suppressed for dmake?
611 * target The target we are building, for error msgs
612 * command The command we ran, for error msgs
613 * running_pid The pid of the process we are waiting for
614 *
615 * Static variables used:
616 * filter_file The fd for the filter file
617 * filter_file_name The name of the filter file
618 *
619 * Global variables used:
620 * filter_stderr Set if -X is on
621 */
622 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
623 Boolean
624 await(register Boolean ignore_error, register Boolean silent_error, Name target, wchar_t *command, pid_t running_pid, Boolean send_mtool_msgs, XDR *xdrs_p, int job_msg_id)
625 #else
626 Boolean
627 await(register Boolean ignore_error, register Boolean silent_error, Name target, wchar_t *command, pid_t running_pid, Boolean send_mtool_msgs, void *xdrs_p, int job_msg_id)
628 #endif
629 {
630 int status;
631 char *buffer;
632 int core_dumped;
633 int exit_status;
634 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
635 Avo_CmdOutput *make_output_msg;
636 #endif
637 FILE *outfp;
638 register pid_t pid;
639 struct stat stat_buff;
640 int termination_signal;
641 char tmp_buf[MAXPATHLEN];
642 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
643 RWCollectable *xdr_msg;
644 #endif
645
646 while ((pid = wait(&status)) != running_pid) {
647 if (pid == -1) {
648 fatal_mksh(catgets(libmksdmsi18n_catd, 1, 98, "wait() failed: %s"), errmsg(errno));
649 }
650 }
651 (void) fflush(stdout);
652 (void) fflush(stderr);
653
654 if (status == 0) {
655
656 #ifdef PRINT_EXIT_STATUS
657 warning_mksh(NOCATGETS("I'm in await(), and status is 0."));
658 #endif
659
660 return succeeded;
661 }
662
663 #ifdef PRINT_EXIT_STATUS
664 warning_mksh(NOCATGETS("I'm in await(), and status is *NOT* 0."));
665 #endif
666
667
668 exit_status = WEXITSTATUS(status);
669
670 #ifdef PRINT_EXIT_STATUS
671 warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status);
672 #endif
673
674 termination_signal = WTERMSIG(status);
675 core_dumped = WCOREDUMP(status);
676
677 /*
678 * If the child returned an error, we now try to print a
679 * nice message about it.
680 */
681 SEND_MTOOL_MSG(
682 make_output_msg = new Avo_CmdOutput();
683 (void) sprintf(tmp_buf, "%d", job_msg_id);
684 make_output_msg->appendOutput(AVO_STRDUP(tmp_buf));
685 );
686
687 tmp_buf[0] = (int) nul_char;
688 if (!silent_error) {
689 if (exit_status != 0) {
690 (void) fprintf(stdout,
691 catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"),
692 exit_status);
693 SEND_MTOOL_MSG(
694 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
695 catgets(libmksdmsi18n_catd, 1, 104, "*** Error code %d"),
696 exit_status);
697 );
698 } else {
699 (void) fprintf(stdout,
700 catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"),
701 termination_signal);
702 SEND_MTOOL_MSG(
703 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
704 catgets(libmksdmsi18n_catd, 1, 106, "*** Signal %d"),
705 termination_signal);
706 );
707 if (core_dumped) {
708 (void) fprintf(stdout,
709 catgets(libmksdmsi18n_catd, 1, 107, " - core dumped"));
710 SEND_MTOOL_MSG(
711 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
712 catgets(libmksdmsi18n_catd, 1, 108, " - core dumped"));
713 );
714 }
715 }
716 if (ignore_error) {
717 (void) fprintf(stdout,
718 catgets(libmksdmsi18n_catd, 1, 109, " (ignored)"));
719 SEND_MTOOL_MSG(
720 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
721 catgets(libmksdmsi18n_catd, 1, 110, " (ignored)"));
722 );
723 }
724 (void) fprintf(stdout, "\n");
725 (void) fflush(stdout);
726 SEND_MTOOL_MSG(
|