stat1 = ferror(bpipe->rfd);
}
if (stat1 < 0) {
- Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno));
+ Dmsg2(150, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno));
} else if (stat1 != 0) {
- Dmsg1(100, "Run program fgets stat=%d\n", stat1);
+ Dmsg1(150, "Run program fgets stat=%d\n", stat1);
if (bpipe->timer_id) {
- Dmsg1(100, "Run program fgets killed=%d\n", bpipe->timer_id->killed);
+ Dmsg1(150, "Run program fgets killed=%d\n", bpipe->timer_id->killed);
/* NB: I'm not sure it is really useful for run_program. Without the
* following lines run_program would not detect if the program was killed
* by the watchdog. */
if (bpipe->timer_id->killed) {
- stat1 = -EPIPE;
- pm_strcat(results, "Program killed by Bacula watchdog (timeout)\n");
+ stat1 = ETIME;
+ pm_strcat(results, _("Program killed by Bacula watchdog (timeout)\n"));
}
}
}
}
stat2 = close_bpipe(bpipe);
stat1 = stat2 != 0 ? stat2 : stat1;
- Dmsg1(100, "Run program returning %d\n", stat1);
+ Dmsg1(150, "Run program returning %d\n", stat1);
return stat1;
}
int stat1, stat2;
char *mode;
POOLMEM* tmp;
+ char *buf;
+ const int bufsize = 32000;
if (results == NULL) {
return run_program(prog, wait, NULL);
sm_check(__FILE__, __LINE__, false);
tmp = get_pool_memory(PM_MESSAGE);
+ buf = (char *)malloc(bufsize+1);
mode = (char *)"r";
bpipe = open_bpipe(prog, wait, mode);
sm_check(__FILE__, __LINE__, false);
tmp[0] = 0;
while (1) {
- char buf[1000];
- fgets(buf, sizeof(buf), bpipe->rfd);
+ buf[0] = 0;
+ fgets(buf, bufsize, bpipe->rfd);
+ buf[bufsize] = 0;
pm_strcat(tmp, buf);
if (feof(bpipe->rfd)) {
stat1 = 0;
} else if (stat1 != 0) {
Dmsg1(900, "Run program fgets stat=%d\n", stat1);
if (bpipe->timer_id) {
- Dmsg1(100, "Run program fgets killed=%d\n", bpipe->timer_id->killed);
+ Dmsg1(150, "Run program fgets killed=%d\n", bpipe->timer_id->killed);
if (bpipe->timer_id->killed) {
- pm_strcat(tmp, "Program killed by Bacula watchdog (timeout)\n");
- stat1 = -EPIPE;
+ pm_strcat(tmp, _("Program killed by Bacula watchdog (timeout)\n"));
+ stat1 = ETIME;
break;
}
}
stat2 = close_bpipe(bpipe);
stat1 = stat2 != 0 ? stat2 : stat1;
- Dmsg1(900, "Run program returning %d\n", stat);
+ Dmsg1(900, "Run program returning %d\n", stat1);
free_pool_memory(tmp);
+ free(buf);
return stat1;
}