ctdb-daemon: Return negative status only if there are known errors
authorAmitay Isaacs <amitay@gmail.com>
Thu, 23 Jan 2014 03:57:53 +0000 (14:57 +1100)
committerMartin Schwenke <martin@meltin.net>
Fri, 31 Jan 2014 04:57:49 +0000 (15:57 +1100)
If event script does not exist or does not have execute permissions, then
return negative errno to distinguish from the exit errors of event script.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_event_helper.c

index 4c62e41af631e9bc62452564c7087733037f64a5..ab1eae44091b19f822cdbd5483dd6ae7903f3740 100644 (file)
@@ -127,7 +127,10 @@ int main(int argc, char *argv[])
 
        waitpid(pid, &status, 0);
        if (WIFEXITED(status)) {
-               output = -WEXITSTATUS(status);
+               output = WEXITSTATUS(status);
+               if (output == ENOENT || output == ENOEXEC) {
+                       output = -output;
+               }
                write(write_fd, &output, sizeof(output));
                exit(output);
        }