daemon: Correctly process the exit code from failed eventscripts
authorAmitay Isaacs <amitay@gmail.com>
Tue, 21 Jul 2015 06:37:04 +0000 (16:37 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 31 Jul 2015 03:35:01 +0000 (13:35 +1000)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Jul 22 15:03:53 CEST 2015 on sn-devel-104

(Imported from commit 00ec3c477eba50206801b451ae4eb64c12aba5db)

server/ctdb_event_helper.c

index f14e336f25cfe7d88f1fcba884c4a9ba54e7b294..a1b531882251d5a9e491f530fd61a378dabf9e64 100644 (file)
@@ -128,7 +128,11 @@ int main(int argc, char *argv[])
                exit(1);
        }
        if (WIFEXITED(status)) {
-               output = -WEXITSTATUS(status);
+               output = WEXITSTATUS(status);
+               /* Only errors should be returned as -ve values */
+               if (output == ENOENT || output == ENOEXEC) {
+                       output = -output;
+               }
                sys_write(write_fd, &output, sizeof(output));
                exit(0);
        }