Print this page
make: ship the Joyent patch to enable parallel make (originally from rm)


  20  */
  21 /*
  22  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 
  27 /*
  28  *      dosys.cc
  29  *
  30  *      Execute one commandline
  31  */
  32 
  33 /*
  34  * Included files
  35  */
  36 #include <sys/wait.h>                     /* WIFEXITED(status) */
  37 #include <alloca.h>               /* alloca() */
  38 
  39 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL) /* tolik */
  40 #       include <avo/strings.h>   /* AVO_STRDUP() */
  41 #if defined(DISTRIBUTED)
  42 #       include <dm/Avo_CmdOutput.h>
  43 #       include <rw/xdrstrea.h>
  44 #endif
  45 #endif
  46 
  47 #include <stdio.h>                /* errno */
  48 #include <errno.h>                /* errno */
  49 #include <fcntl.h>                /* open() */
  50 #include <mksh/dosys.h>
  51 #include <mksh/macro.h>           /* getvar() */
  52 #include <mksh/misc.h>            /* getmem(), fatal_mksh(), errmsg() */
  53 #include <mksdmsi18n/mksdmsi18n.h>        /* libmksdmsi18n_init() */
  54 #include <sys/signal.h>           /* SIG_DFL */
  55 #include <sys/stat.h>             /* open() */
  56 #include <sys/wait.h>             /* wait() */
  57 #include <ulimit.h>               /* ulimit() */
  58 #include <unistd.h>               /* close(), dup2() */
  59 
  60 


 618         warning_mksh(NOCATGETS("I'm in await(), and status is *NOT* 0."));
 619 #endif
 620 
 621 
 622         exit_status = WEXITSTATUS(status);
 623 
 624 #ifdef PRINT_EXIT_STATUS
 625         warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status);
 626 #endif
 627 
 628         termination_signal = WTERMSIG(status);
 629         core_dumped = WCOREDUMP(status);
 630 
 631         /*
 632          * If the child returned an error, we now try to print a
 633          * nice message about it.
 634          */
 635         SEND_MTOOL_MSG(
 636                 make_output_msg = new Avo_CmdOutput();
 637                 (void) sprintf(tmp_buf, "%d", job_msg_id);
 638                 make_output_msg->appendOutput(AVO_STRDUP(tmp_buf));
 639         );
 640 
 641         tmp_buf[0] = (int) nul_char;
 642         if (!silent_error) {
 643                 if (exit_status != 0) {
 644                         (void) fprintf(stdout,
 645                                        catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"),
 646                                        exit_status);
 647                         SEND_MTOOL_MSG(
 648                                 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 649                                                catgets(libmksdmsi18n_catd, 1, 104, "*** Error code %d"),
 650                                                exit_status);
 651                         );
 652                 } else {
 653                                 (void) fprintf(stdout,
 654                                                catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"),
 655                                                termination_signal);
 656                                 SEND_MTOOL_MSG(
 657                                         (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 658                                                        catgets(libmksdmsi18n_catd, 1, 106, "*** Signal %d"),


 661                         if (core_dumped) {
 662                                 (void) fprintf(stdout,
 663                                                catgets(libmksdmsi18n_catd, 1, 107, " - core dumped"));
 664                                 SEND_MTOOL_MSG(
 665                                         (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 666                                                        catgets(libmksdmsi18n_catd, 1, 108, " - core dumped"));
 667                                 );
 668                         }
 669                 }
 670                 if (ignore_error) {
 671                         (void) fprintf(stdout,
 672                                        catgets(libmksdmsi18n_catd, 1, 109, " (ignored)"));
 673                         SEND_MTOOL_MSG(
 674                                 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 675                                                catgets(libmksdmsi18n_catd, 1, 110, " (ignored)"));
 676                         );
 677                 }
 678                 (void) fprintf(stdout, "\n");
 679                 (void) fflush(stdout);
 680                 SEND_MTOOL_MSG(
 681                         make_output_msg->appendOutput(AVO_STRDUP(tmp_buf));
 682                 );
 683         }
 684         SEND_MTOOL_MSG(
 685                 xdr_msg = (RWCollectable*) make_output_msg;
 686                 xdr(xdrs_p, xdr_msg);
 687                 delete make_output_msg;
 688         );
 689 
 690 #ifdef PRINT_EXIT_STATUS
 691         warning_mksh(NOCATGETS("I'm in await(), returning failed."));
 692 #endif
 693 
 694         return failed;
 695 }
 696 
 697 /*
 698  *      sh_command2string(command, destination)
 699  *
 700  *      Run one sh command and capture the output from it.
 701  *




  20  */
  21 /*
  22  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 
  27 /*
  28  *      dosys.cc
  29  *
  30  *      Execute one commandline
  31  */
  32 
  33 /*
  34  * Included files
  35  */
  36 #include <sys/wait.h>                     /* WIFEXITED(status) */
  37 #include <alloca.h>               /* alloca() */
  38 
  39 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL) /* tolik */

  40 #if defined(DISTRIBUTED)
  41 #       include <dm/Avo_CmdOutput.h>
  42 #       include <rw/xdrstrea.h>
  43 #endif
  44 #endif
  45 
  46 #include <stdio.h>                /* errno */
  47 #include <errno.h>                /* errno */
  48 #include <fcntl.h>                /* open() */
  49 #include <mksh/dosys.h>
  50 #include <mksh/macro.h>           /* getvar() */
  51 #include <mksh/misc.h>            /* getmem(), fatal_mksh(), errmsg() */
  52 #include <mksdmsi18n/mksdmsi18n.h>        /* libmksdmsi18n_init() */
  53 #include <sys/signal.h>           /* SIG_DFL */
  54 #include <sys/stat.h>             /* open() */
  55 #include <sys/wait.h>             /* wait() */
  56 #include <ulimit.h>               /* ulimit() */
  57 #include <unistd.h>               /* close(), dup2() */
  58 
  59 


 617         warning_mksh(NOCATGETS("I'm in await(), and status is *NOT* 0."));
 618 #endif
 619 
 620 
 621         exit_status = WEXITSTATUS(status);
 622 
 623 #ifdef PRINT_EXIT_STATUS
 624         warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status);
 625 #endif
 626 
 627         termination_signal = WTERMSIG(status);
 628         core_dumped = WCOREDUMP(status);
 629 
 630         /*
 631          * If the child returned an error, we now try to print a
 632          * nice message about it.
 633          */
 634         SEND_MTOOL_MSG(
 635                 make_output_msg = new Avo_CmdOutput();
 636                 (void) sprintf(tmp_buf, "%d", job_msg_id);
 637                 make_output_msg->appendOutput(strdup(tmp_buf));
 638         );
 639 
 640         tmp_buf[0] = (int) nul_char;
 641         if (!silent_error) {
 642                 if (exit_status != 0) {
 643                         (void) fprintf(stdout,
 644                                        catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"),
 645                                        exit_status);
 646                         SEND_MTOOL_MSG(
 647                                 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 648                                                catgets(libmksdmsi18n_catd, 1, 104, "*** Error code %d"),
 649                                                exit_status);
 650                         );
 651                 } else {
 652                                 (void) fprintf(stdout,
 653                                                catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"),
 654                                                termination_signal);
 655                                 SEND_MTOOL_MSG(
 656                                         (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 657                                                        catgets(libmksdmsi18n_catd, 1, 106, "*** Signal %d"),


 660                         if (core_dumped) {
 661                                 (void) fprintf(stdout,
 662                                                catgets(libmksdmsi18n_catd, 1, 107, " - core dumped"));
 663                                 SEND_MTOOL_MSG(
 664                                         (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 665                                                        catgets(libmksdmsi18n_catd, 1, 108, " - core dumped"));
 666                                 );
 667                         }
 668                 }
 669                 if (ignore_error) {
 670                         (void) fprintf(stdout,
 671                                        catgets(libmksdmsi18n_catd, 1, 109, " (ignored)"));
 672                         SEND_MTOOL_MSG(
 673                                 (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 674                                                catgets(libmksdmsi18n_catd, 1, 110, " (ignored)"));
 675                         );
 676                 }
 677                 (void) fprintf(stdout, "\n");
 678                 (void) fflush(stdout);
 679                 SEND_MTOOL_MSG(
 680                         make_output_msg->appendOutput(strdup(tmp_buf));
 681                 );
 682         }
 683         SEND_MTOOL_MSG(
 684                 xdr_msg = (RWCollectable*) make_output_msg;
 685                 xdr(xdrs_p, xdr_msg);
 686                 delete make_output_msg;
 687         );
 688 
 689 #ifdef PRINT_EXIT_STATUS
 690         warning_mksh(NOCATGETS("I'm in await(), returning failed."));
 691 #endif
 692 
 693         return failed;
 694 }
 695 
 696 /*
 697  *      sh_command2string(command, destination)
 698  *
 699  *      Run one sh command and capture the output from it.
 700  *