X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Flib%2Fbpipe.c;h=975c5f6896f5efbec918dbbc07091f58a9f6c8f7;hb=3ab946b1d2677cb3d8095e54767487d569457542;hp=729d5e2a10e10f071da245d44b5299ea73ebe0bf;hpb=371d1362e703c29a2ca2a96876b6b4a257e4b30f;p=bacula%2Fbacula diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index 729d5e2a10..975c5f6896 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -163,7 +163,7 @@ int close_bpipe(BPIPE *bpipe) break; } if (remaining_wait > 0) { - sleep(1); /* wait one second */ + bmicrosleep(1, 0); /* wait one second */ remaining_wait--; } else { stat = 1; /* set error status */ @@ -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; }