chiark / gitweb /
shared: add formats-util.h
[elogind.git] / src / login / inhibit.c
index db977ccc59b133ed87117b5ec9060e1e3e306df6..1f78e4b883d565179a354da6ffe19196e6fd403e 100644 (file)
@@ -20,7 +20,6 @@
 ***/
 
 #include <getopt.h>
-#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -32,6 +31,7 @@
 #include "util.h"
 #include "build.h"
 #include "strv.h"
+#include "formats-util.h"
 
 static const char* arg_what = "idle:sleep:shutdown";
 static const char* arg_who = NULL;
@@ -260,13 +260,13 @@ int main(int argc, char *argv[]) {
 
                 fd = inhibit(bus, &error);
                 if (fd < 0) {
-                        log_error("Failed to inhibit: %s", bus_error_message(&error, -r));
+                        log_error("Failed to inhibit: %s", bus_error_message(&error, fd));
                         return EXIT_FAILURE;
                 }
 
                 pid = fork();
                 if (pid < 0) {
-                        log_error("Failed to fork: %m");
+                        log_error_errno(errno, "Failed to fork: %m");
                         return EXIT_FAILURE;
                 }
 
@@ -276,11 +276,11 @@ int main(int argc, char *argv[]) {
                         close_all_fds(NULL, 0);
 
                         execvp(argv[optind], argv + optind);
-                        log_error("Failed to execute %s: %m", argv[optind]);
+                        log_error_errno(errno, "Failed to execute %s: %m", argv[optind]);
                         _exit(EXIT_FAILURE);
                 }
 
-                r = wait_for_terminate_and_warn(argv[optind], pid);
+                r = wait_for_terminate_and_warn(argv[optind], pid, true);
                 return r < 0 ? EXIT_FAILURE : r;
         }