***/
#include <getopt.h>
-#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "util.h"
#include "build.h"
#include "strv.h"
+#include "formats-util.h"
+#include "process-util.h"
+#include "signal-util.h"
static const char* arg_what = "idle:sleep:shutdown";
static const char* arg_who = NULL;
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;
}
if (pid == 0) {
/* Child */
+ (void) reset_all_signal_handlers();
+ (void) reset_signal_mask();
+
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;
}