Changeset 2357 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-fork.c
- Timestamp:
- Aug 29, 2009, 3:22:10 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-fork.c
r2339 r2357 38 38 /*@ buffers ***************************************************** */ 39 39 static char result[512]; 40 char *tmp ;40 char *tmp = NULL; 41 41 42 42 /*@ pointers **************************************************** */ … … 44 44 45 45 /*@ initialize data ********************************************* */ 46 malloc_string(tmp);47 46 result[0] = '\0'; 48 tmp[0] = '\0';49 47 50 48 /*@******************************************************************** */ … … 52 50 assert_string_is_neither_NULL_nor_zerolength(call); 53 51 if ((fin = popen(call, "r"))) { 54 for (fgets(tmp, MAX_STR_LEN, fin); !feof(fin); 55 fgets(tmp, MAX_STR_LEN, fin)) { 52 for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) { 56 53 if (strlen(tmp) > 1) { 57 strcpy(result, tmp); 58 } 59 } 54 strncpy(result, 511, tmp); 55 } 56 mr_free(tmp); 57 } 58 mr_free(tmp); 60 59 paranoid_pclose(fin); 61 60 } else { … … 63 62 } 64 63 strip_spaces(result); 65 paranoid_free(tmp);66 64 return (result); 67 65 } … … 163 161 mr_free(command); 164 162 command = tmp2; 165 #ifndef _XWIN166 163 if (!g_text_mode) { 167 164 newtSuspend(); 168 165 } 169 #endif170 166 log_msg(1, "command = '%s'", command); 171 167 retval += system(command); … … 294 290 fin = fopen(tmp1, "r"); 295 291 if (fin) { 296 for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); 297 fgets(incoming, MAX_STR_LEN, fin)) { 292 for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin); fgets(incoming, MAX_STR_LEN, fin)) { 298 293 p = incoming; 299 294 while (p && *p) { … … 304 299 } 305 300 strip_spaces(incoming); 306 if ((res == 0 && log_if_success) 307 || (res != 0 && log_if_failure)) { 301 if ((res == 0 && log_if_success) || (res != 0 && log_if_failure)) { 308 302 log_msg(0, incoming); 309 303 } … … 375 369 } 376 370 } 377 #ifdef _XWIN 378 /* This only can update when newline goes into the file, 379 but it's *much* prettier/faster on Qt. */ 380 while (does_file_exist(lockfile)) { 381 while (!feof(fin)) { 382 if (!fgets(tmp1, 512, fin)) 383 break; 384 log_to_screen(tmp1); 385 } 386 usleep(500000); 387 } 388 #else 389 /* This works on Newt, and it gives quicker updates. */ 371 390 372 for (; does_file_exist(lockfile); sleep(1)) { 391 373 log_file_end_to_screen(MONDO_LOGFILE, ""); 392 374 update_evalcall_form(1); 393 375 } 394 #endif 376 395 377 /* Evaluate the status returned by pclose to get the exit code of the called program. */ 396 378 errno = 0;
Note:
See TracChangeset
for help on using the changeset viewer.