Ignore:
Timestamp:
Jul 10, 2008, 6:37:04 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • Protect recursive remove of tempdir with test on the look and feel of that dir to avoid removing blindly useful dir :-(
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.7/mondo/src/common/libmondo-fork.c

    r1784 r1999  
    701701
    702702
    703 
    704 
    705 
    706 int run_external_binary_with_percentage_indicator_OLD(char *tt, char *cmd)
    707 {
    708 
    709     /*@ int *************************************************************** */
    710     int res = 0;
    711     int percentage = 0;
    712     int maxpc = 0;
    713     int pcno = 0;
    714     int last_pcno = 0;
    715 
    716     /*@ buffers *********************************************************** */
    717     char *command;
    718     char *tempfile;
    719     char *title;
    720     /*@ pointers ********************************************************** */
    721     FILE *pin;
    722 
    723     malloc_string(title);
    724     malloc_string(command);
    725     malloc_string(tempfile);
    726     assert_string_is_neither_NULL_nor_zerolength(cmd);
    727     assert_string_is_neither_NULL_nor_zerolength(title);
    728 
    729     strcpy(title, tt);
    730     sprintf(tempfile, "%s/mondo.binperc", bkpinfo->tmpdir);
    731     sprintf(command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
    732             tempfile);
    733     log_msg(3, command);
    734     open_evalcall_form(title);
    735     if (!(pin = popen(command, "r"))) {
    736         log_OS_error("fmt err");
    737         return (1);
    738     }
    739     maxpc = 100;
    740 // OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
    741     for (sleep(1); does_file_exist(tempfile); sleep(1)) {
    742         pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE);
    743         if (pcno < 0 || pcno > 100) {
    744             log_msg(5, "Weird pc#");
    745             continue;
    746         }
    747         percentage = pcno * 100 / maxpc;
    748         if (pcno <= 5 && last_pcno > 40) {
    749             close_evalcall_form();
    750             strcpy(title, "Verifying...");
    751             open_evalcall_form(title);
    752         }
    753         last_pcno = pcno;
    754         update_evalcall_form(percentage);
    755     }
    756 // OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
    757     close_evalcall_form();
    758     if (pclose(pin)) {
    759         res++;
    760         log_OS_error("Unable to pclose");
    761     }
    762     unlink(tempfile);
    763     paranoid_free(command);
    764     paranoid_free(tempfile);
    765     paranoid_free(title);
    766     return (res);
    767 }
    768 
    769 
    770 
    771 
    772703void *run_prog_in_bkgd_then_exit(void *info)
    773704{
Note: See TracChangeset for help on using the changeset viewer.