From: Kern Sibbald Date: Mon, 10 Feb 2003 21:35:47 +0000 (+0000) Subject: Fix run_program return status X-Git-Tag: Release-1.30~126 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=07a622655345097c456acf9a807a66fcf00c11db;p=bacula%2Fbacula Fix run_program return status git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@341 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 5f8d1e5f32..c87c9df56a 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -16,6 +16,9 @@ Testing to do: (painful) - multiple simultaneous Volumes For 1.30 release: +- Change stat1= fgets()!=NULL to stat1=fgest()==NULL; in + run_program -- bpipe.c +- Add RunBeforeJob and RunAfterJob to the Client program. - Have SD compute MD5 or SHA1 and compare to what FD computes. - Make VolumeToCatalog calculate an MD5 or SHA1 from the actual data on the Volume and compare it. @@ -834,4 +837,3 @@ Done: (see kernsdone for more) - Implement multiple simultaneous file Volumes on a single device. - Cleanup db_update_media and db_update_pool - Flush all the daemon messages at the end of every job. - diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index 729d5e2a10..7b284c9ce9 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -197,6 +197,11 @@ int close_bpipe(BPIPE *bpipe) * Run an external program. Optionally wait a specified number * of seconds. Program killed if wait exceeded. Optionally * return the output from the program (normally a single line). + * + * Contrary to my normal calling conventions, this program + * + * Returns: 0 on success + * non-zero on error */ int run_program(char *prog, int wait, POOLMEM *results) { @@ -211,12 +216,12 @@ int run_program(char *prog, int wait, POOLMEM *results) } if (results) { results[0] = 0; - stat1 = fgets(results, sizeof_pool_memory(results), bpipe->rfd) != NULL; + stat1 = fgets(results, sizeof_pool_memory(results), bpipe->rfd) == NULL; } else { - stat1 = 1; + stat1 = 0; } stat2 = close_bpipe(bpipe); - return stat1 && stat2; + return stat2 != 0 ? stat2 : stat1; } diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index ab69174604..ebe6031ced 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -420,6 +420,7 @@ int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir) changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "loaded"); status = run_program(changer, timeout, results); + Dmsg3(100, "run_prog: %s stat=%d result=%s\n", changer, status, results); if (status == 0) { loaded = atoi(results); } else {