Print this page
make: unifdef for REDIRECT_ERR (defined)


 832                         if (*tmp_index_str_ptr == (int) hyphen_char) {
 833                                 tmp_index_str_ptr++;
 834                         }
 835                         (void) fprintf(stdout, "%s\n", tmp_index_str_ptr);
 836                     }
 837                     tmp_index++;
 838                 }
 839                 (void) fflush(stdout);
 840         }
 841 
 842         (void) sprintf(mbstring,
 843                         NOCATGETS("%s/dmake.stdout.%d.%d.XXXXXX"),
 844                         tmpdir,
 845                         getpid(),
 846                         file_number++);
 847 
 848         mktemp(mbstring);
 849 
 850         stdout_file = strdup(mbstring);
 851         stderr_file = NULL;
 852 #if defined (TEAMWARE_MAKE_CMN) && defined(REDIRECT_ERR)
 853         if (!out_err_same) {
 854                 (void) sprintf(mbstring,
 855                                 NOCATGETS("%s/dmake.stderr.%d.%d.XXXXXX"),
 856                                 tmpdir,
 857                                 getpid(),
 858                                 file_number++);
 859 
 860                 mktemp(mbstring);
 861 
 862                 stderr_file = strdup(mbstring);
 863         }
 864 #endif
 865 
 866         process_running = run_rule_commands(local_host, commands);
 867 
 868         return build_running;
 869 }
 870 
 871 /*
 872  *      doname_parallel(target, do_get, implicit)


1452                                         }
1453                                         if ((line2 != NULL) &&
1454                                             (out_buf.st_size > 0)) {
1455                                                 cmds_length = 0;
1456                                                 for (rule = line2->body.line.command_used,
1457                                                      silent_flag = silent;
1458                                                      rule != NULL;
1459                                                      rule = rule->next) {
1460                                                         cmds_length += rule->command_line->hash.length + 1;
1461                                                         silent_flag = BOOLEAN(silent_flag || rule->silent);
1462                                                 }
1463                                                 if (out_buf.st_size != cmds_length || silent_flag ||
1464                                                     output_mode == txt2_mode) {
1465                                                         dump_out_file(rp->stdout_file, false);
1466                                                 }
1467                                         }
1468                                         (void) unlink(rp->stdout_file);
1469                                         retmem_mb(rp->stdout_file);
1470                                         rp->stdout_file = NULL;
1471                                 }
1472 #if defined(REDIRECT_ERR)
1473                                 if (!out_err_same && (rp->stderr_file != NULL)) {
1474                                         if (stat(rp->stderr_file, &out_buf) < 0) {
1475                                                 fatal(catgets(catd, 1, 130, "stat of %s failed: %s"),
1476                                                       rp->stderr_file,
1477                                                       errmsg(errno));
1478                                         }
1479                                         if ((line2 != NULL) &&
1480                                             (out_buf.st_size > 0)) {
1481                                                 dump_out_file(rp->stderr_file, true);
1482                                         }
1483                                         (void) unlink(rp->stderr_file);
1484                                         retmem_mb(rp->stderr_file);
1485                                         rp->stderr_file = NULL;
1486                                 }
1487 #endif
1488                         }
1489                         check_state(rp->temp_file);
1490                         if (rp->temp_file != NULL) {
1491                                 free_name(rp->temp_file);
1492                         }
1493                         rp->temp_file = NULL;
1494                         if (rp->state == build_failed) {
1495                                 line = get_prop(rp->target->prop, line_prop);
1496                                 if (line != NULL) {
1497                                         line->body.line.command_used = NULL;
1498                                 }
1499                                 if (continue_after_error ||
1500                                     fatal_in_progress ||
1501                                     !docheck) {
1502                                         warning(catgets(catd, 1, 256, "Command failed for target `%s'"),
1503                                                 rp->command ? line2->body.line.target->string_mb : rp->target->string_mb);
1504                                         build_failed_seen = true;
1505                                 } else {
1506                                         /*
1507                                          * XXX??? - DMake needs to exit(),


2017 static pid_t
2018 run_rule_commands(char *host, char **commands)
2019 {
2020         Boolean         always_exec;
2021         Name            command;
2022         Boolean         ignore;
2023         int             length;
2024         Doname          result;
2025         Boolean         silent_flag;
2026         wchar_t         *tmp_wcs_buffer;
2027 
2028         childPid = fork();
2029         switch (childPid) {
2030         case -1:        /* Error */
2031                 fatal(catgets(catd, 1, 337, "Could not fork child process for dmake job: %s"),
2032                       errmsg(errno));
2033                 break;
2034         case 0:         /* Child */
2035                 /* To control the processed targets list is not the child's business */
2036                 running_list = NULL;
2037 #if defined(REDIRECT_ERR)
2038                 if(out_err_same) {
2039                         redirect_io(stdout_file, (char*)NULL);
2040                 } else {
2041                         redirect_io(stdout_file, stderr_file);
2042                 }
2043 #else
2044                 redirect_io(stdout_file, (char*)NULL);
2045 #endif
2046                 for (commands = commands;
2047                      (*commands != (char *)NULL);
2048                      commands++) {
2049                         silent_flag = silent;
2050                         ignore = false;
2051                         always_exec = false;
2052                         while ((**commands == (int) at_char) ||
2053                                (**commands == (int) hyphen_char) ||
2054                                (**commands == (int) plus_char)) {
2055                                 if (**commands == (int) at_char) {
2056                                         silent_flag = true;
2057                                 }
2058                                 if (**commands == (int) hyphen_char) {
2059                                         ignore = true;
2060                                 }
2061                                 if (**commands == (int) plus_char) {
2062                                         always_exec = true;
2063                                 }
2064                                 (*commands)++;
2065                         }




 832                         if (*tmp_index_str_ptr == (int) hyphen_char) {
 833                                 tmp_index_str_ptr++;
 834                         }
 835                         (void) fprintf(stdout, "%s\n", tmp_index_str_ptr);
 836                     }
 837                     tmp_index++;
 838                 }
 839                 (void) fflush(stdout);
 840         }
 841 
 842         (void) sprintf(mbstring,
 843                         NOCATGETS("%s/dmake.stdout.%d.%d.XXXXXX"),
 844                         tmpdir,
 845                         getpid(),
 846                         file_number++);
 847 
 848         mktemp(mbstring);
 849 
 850         stdout_file = strdup(mbstring);
 851         stderr_file = NULL;
 852 #if defined (TEAMWARE_MAKE_CMN)
 853         if (!out_err_same) {
 854                 (void) sprintf(mbstring,
 855                                 NOCATGETS("%s/dmake.stderr.%d.%d.XXXXXX"),
 856                                 tmpdir,
 857                                 getpid(),
 858                                 file_number++);
 859 
 860                 mktemp(mbstring);
 861 
 862                 stderr_file = strdup(mbstring);
 863         }
 864 #endif
 865 
 866         process_running = run_rule_commands(local_host, commands);
 867 
 868         return build_running;
 869 }
 870 
 871 /*
 872  *      doname_parallel(target, do_get, implicit)


1452                                         }
1453                                         if ((line2 != NULL) &&
1454                                             (out_buf.st_size > 0)) {
1455                                                 cmds_length = 0;
1456                                                 for (rule = line2->body.line.command_used,
1457                                                      silent_flag = silent;
1458                                                      rule != NULL;
1459                                                      rule = rule->next) {
1460                                                         cmds_length += rule->command_line->hash.length + 1;
1461                                                         silent_flag = BOOLEAN(silent_flag || rule->silent);
1462                                                 }
1463                                                 if (out_buf.st_size != cmds_length || silent_flag ||
1464                                                     output_mode == txt2_mode) {
1465                                                         dump_out_file(rp->stdout_file, false);
1466                                                 }
1467                                         }
1468                                         (void) unlink(rp->stdout_file);
1469                                         retmem_mb(rp->stdout_file);
1470                                         rp->stdout_file = NULL;
1471                                 }
1472 
1473                                 if (!out_err_same && (rp->stderr_file != NULL)) {
1474                                         if (stat(rp->stderr_file, &out_buf) < 0) {
1475                                                 fatal(catgets(catd, 1, 130, "stat of %s failed: %s"),
1476                                                       rp->stderr_file,
1477                                                       errmsg(errno));
1478                                         }
1479                                         if ((line2 != NULL) &&
1480                                             (out_buf.st_size > 0)) {
1481                                                 dump_out_file(rp->stderr_file, true);
1482                                         }
1483                                         (void) unlink(rp->stderr_file);
1484                                         retmem_mb(rp->stderr_file);
1485                                         rp->stderr_file = NULL;
1486                                 }

1487                         }
1488                         check_state(rp->temp_file);
1489                         if (rp->temp_file != NULL) {
1490                                 free_name(rp->temp_file);
1491                         }
1492                         rp->temp_file = NULL;
1493                         if (rp->state == build_failed) {
1494                                 line = get_prop(rp->target->prop, line_prop);
1495                                 if (line != NULL) {
1496                                         line->body.line.command_used = NULL;
1497                                 }
1498                                 if (continue_after_error ||
1499                                     fatal_in_progress ||
1500                                     !docheck) {
1501                                         warning(catgets(catd, 1, 256, "Command failed for target `%s'"),
1502                                                 rp->command ? line2->body.line.target->string_mb : rp->target->string_mb);
1503                                         build_failed_seen = true;
1504                                 } else {
1505                                         /*
1506                                          * XXX??? - DMake needs to exit(),


2016 static pid_t
2017 run_rule_commands(char *host, char **commands)
2018 {
2019         Boolean         always_exec;
2020         Name            command;
2021         Boolean         ignore;
2022         int             length;
2023         Doname          result;
2024         Boolean         silent_flag;
2025         wchar_t         *tmp_wcs_buffer;
2026 
2027         childPid = fork();
2028         switch (childPid) {
2029         case -1:        /* Error */
2030                 fatal(catgets(catd, 1, 337, "Could not fork child process for dmake job: %s"),
2031                       errmsg(errno));
2032                 break;
2033         case 0:         /* Child */
2034                 /* To control the processed targets list is not the child's business */
2035                 running_list = NULL;

2036                 if(out_err_same) {
2037                         redirect_io(stdout_file, (char*)NULL);
2038                 } else {
2039                         redirect_io(stdout_file, stderr_file);
2040                 }



2041                 for (commands = commands;
2042                      (*commands != (char *)NULL);
2043                      commands++) {
2044                         silent_flag = silent;
2045                         ignore = false;
2046                         always_exec = false;
2047                         while ((**commands == (int) at_char) ||
2048                                (**commands == (int) hyphen_char) ||
2049                                (**commands == (int) plus_char)) {
2050                                 if (**commands == (int) at_char) {
2051                                         silent_flag = true;
2052                                 }
2053                                 if (**commands == (int) hyphen_char) {
2054                                         ignore = true;
2055                                 }
2056                                 if (**commands == (int) plus_char) {
2057                                         always_exec = true;
2058                                 }
2059                                 (*commands)++;
2060                         }