/* Fire off Alert command and include any output */
if (jcr->device->alert_command) {
POOLMEM *alert;
- int status;
+ int status = 1;
BPIPE *bpipe;
char line[MAXSTRING];
alert = get_pool_memory(PM_FNAME);
alert = edit_device_codes(jcr, alert, jcr->device->alert_command, "");
bpipe = open_bpipe(alert, 0, "r");
- free_pool_memory(alert);
- while (fgets(line, sizeof(line), bpipe->rfd)) {
- Jmsg(jcr, M_INFO, 0, _("Alert: %s"), line);
+ if (bpipe) {
+ free_pool_memory(alert);
+ while (fgets(line, sizeof(line), bpipe->rfd)) {
+ Jmsg(jcr, M_INFO, 0, _("Alert: %s"), line);
+ }
+ status = close_bpipe(bpipe);
}
- status = close_bpipe(bpipe);
if (status != 0) {
berrno be;
be.set_errno(status);