Changeset 688 in MondoRescue for trunk/mondo/mondo/common/libmondo-fork.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-fork.c
r687 r688 1 /* libmondo-fork.c 2 $Id$ 3 4 - subroutines for handling forking/pthreads/etc. 5 6 7 01/20/2006 8 - replaced partimagehack with ntfsclone 9 10 06/20/2004 11 - create fifo /var/log/partimagehack-debug.log and empty it 12 to keep ramdisk from filling up 13 14 04/13/2004 15 - >= should be <= g_loglevel 16 17 11/15/2003 18 - changed a few []s to char*s 19 20 10/12 21 - rewrote partimagehack handling (multiple fifos, chunks, etc.) 22 23 10/11 24 - partimagehack now has debug level of N (set in my-stuff.h) 25 26 10/08 27 - call to partimagehack when restoring will now log errors to /var/log/....log 28 29 10/06 30 - cleaned up logging a bit 31 32 09/30 33 - line 735 - missing char* cmd in sprintf() 34 35 09/28 36 - added run_external_binary_with_percentage_indicator() 37 - rewritten eval_call_to_make_ISO() 38 39 09/18 40 - call mkstemp instead of mktemp 41 42 09/13 43 - major NTFS hackage 44 45 09/12 46 - paranoid_system("rm -f /tmp/ *PARTIMAGE*") before calling partimagehack 47 48 09/11 49 - forward-ported unbroken feed_*_partimage() subroutines 50 from early August 2003 51 52 09/08 53 - detect & use partimagehack if it exists 54 55 09/05 56 - finally finished partimagehack hack :) 57 58 07/04 59 - added subroutines to wrap around partimagehack 60 61 04/27 62 - don't echo (...res=%d...) at end of log_it() 63 unnecessarily 64 - replace newtFinished() and newtInit() with 65 newtSuspend() and newtResume() 66 67 04/24 68 - added some assert()'s and log_OS_error()'s 69 70 04/09 71 - cleaned up run_program_and_log_output() 72 73 04/07 74 - cleaned up code a bit 75 - let run_program_and_log_output() accept -1 (only log if _no error_) 76 77 01/02/2003 78 - in eval_call_to_make_ISO(), append output to MONDO_LOGFILE 79 instead of a temporary stderr text file 80 81 12/10 82 - patch by Heiko Schlittermann to handle % chars in issue.net 83 84 11/18 85 - if mkisofs in eval_call_to_make_ISO() returns an error then return it, 86 whether ISO was created or not 87 88 10/30 89 - if mkisofs in eval_call_to_make_ISO() returns an error then find out if 90 the output (ISO) file has been created; if it has then return 0 anyway 91 92 08/01 - 09/30 93 - run_program_and_log_output() now takes boolean operator to specify 94 whether it will log its activities in the event of _success_ 95 - system() now includes 2>/dev/null 96 - enlarged some tmp[]'s 97 - added run_program_and_log_to_screen() and run_program_and_log_output() 98 99 07/24 100 - created 101 */ 102 1 /* libmondo-fork.c - subroutines for handling forking/pthreads/etc. 2 * $Id$ 3 */ 103 4 104 5 #include "my-stuff.h" … … 110 11 #include "libmondo-tools-EXT.h" 111 12 112 /*@unused@*/113 //static char cvsid[] = "$Id$";114 115 13 extern char *g_tmpfs_mountpt; 116 14 extern t_bkptype g_backup_media_type; … … 123 21 * @param call The program to run. 124 22 * @return The last line of its output. 125 * @note The returned value points to static storage that will be overwritten with each call.23 * @note The returned value should be freed by caller 126 24 */ 127 25 char *call_program_and_get_last_line_of_output(char *call) 128 26 { 129 /*@ buffers ***************************************************** */ 130 static char *result = NULL; 131 char *tmp = NULL; 132 133 /*@ pointers **************************************************** */ 134 FILE *fin; 135 27 char *result = NULL; 28 FILE *fin = NULL; 136 29 size_t n = 0; 137 30 138 /*@******************************************************************** */139 140 31 assert_string_is_neither_NULL_nor_zerolength(call); 32 141 33 if ((fin = popen(call, "r"))) { 142 for (getline(&tmp, &n, fin); !feof(fin); 143 getline(&tmp, &n, fin)) { 144 if (strlen(tmp) > 1) { 145 if (result != NULL) { 146 paranoid_free(result); 147 } 148 asprintf(&result, tmp); 149 } 150 } 34 for (getline(&result, &n, fin); !feof(fin); getline(&result, &n, fin)); 151 35 paranoid_pclose(fin); 152 36 } else { 153 37 log_OS_error("Unable to popen call"); 154 38 } 155 strip_spaces(result); 156 paranoid_free(tmp); 157 return (result); 39 return(result); 158 40 } 159 41 … … 425 307 if (!(fin = popen(command, "r"))) { 426 308 log_OS_error("Unable to popen-in command"); 427 asprintf(&tmp, _("Failed utterly to call '%s'" , command));309 asprintf(&tmp, _("Failed utterly to call '%s'"), command); 428 310 log_to_screen(tmp); 429 311 paranoid_free(tmp); … … 648 530 { 649 531 650 /*@ int *************************************************************** */651 532 int res = 0; 652 533 int percentage = 0; … … 655 536 int last_pcno = 0; 656 537 657 /*@ buffers *********************************************************** */ 658 char *command; 659 char *tempfile; 660 /*@ pointers ********************************************************** */ 661 FILE *pin; 538 char *command = NULL; 539 char *tempfile = NULL; 540 FILE *pin = NULL; 662 541 663 542 assert_string_is_neither_NULL_nor_zerolength(cmd); 664 543 665 asprintf(&tempfile, 666 call_program_and_get_last_line_of_output 667 ("mktemp -q /tmp/mondo.XXXXXXXX")); 544 tempfile = call_program_and_get_last_line_of_output("mktemp -q /tmp/mondo.XXXXXXXX"); 668 545 asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile, 669 546 tempfile);
Note:
See TracChangeset
for help on using the changeset viewer.