***/
#include <errno.h>
-#include <assert.h>
+#include <getopt.h>
#include <string.h>
+#include <sys/prctl.h>
#include <unistd.h>
-#include <getopt.h>
#include "hashmap.h"
-#include "util.h"
-#include "path-util.h"
#include "log.h"
#include "pager.h"
-#include "build.h"
+#include "path-util.h"
+#include "process-util.h"
+#include "signal-util.h"
+#include "string-util.h"
#include "strv.h"
+#include "terminal-util.h"
+#include "util.h"
static const char prefixes[] =
"/etc\0"
return 0;
printf("%s%s%s %s %s %s\n",
- ansi_highlight_red(), "[MASKED]", ansi_highlight_off(),
+ ansi_highlight_red(), "[MASKED]", ansi_normal(),
top, draw_special_char(DRAW_ARROW), bottom);
return 1;
}
return 0;
printf("%s%s%s %s %s %s\n",
- ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight_off(),
+ ansi_highlight_green(), "[EQUIVALENT]", ansi_normal(),
top, draw_special_char(DRAW_ARROW), bottom);
return 1;
}
if (!(arg_flags & SHOW_REDIRECTED))
return 0;
- printf("%s%s%s %s %s %s\n",
- ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(),
+ printf("%s%s%s %s %s %s\n",
+ ansi_highlight(), "[REDIRECTED]", ansi_normal(),
top, draw_special_char(DRAW_ARROW), bottom);
return 1;
}
return 0;
printf("%s%s%s %s %s %s\n",
- ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(),
+ ansi_highlight(), "[OVERRIDDEN]", ansi_normal(),
top, draw_special_char(DRAW_ARROW), bottom);
return 1;
}
return 0;
printf("%s%s%s %s %s %s\n",
- ansi_highlight(), "[EXTENDED]", ansi_highlight_off(),
+ ansi_highlight(), "[EXTENDED]", ansi_normal(),
top, draw_special_char(DRAW_ARROW), bottom);
return 1;
}
fflush(stdout);
pid = fork();
- if (pid < 0) {
- log_error("Failed to fork off diff: %m");
- return -errno;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork off diff: %m");
+ else if (pid == 0) {
+
+ (void) reset_all_signal_handlers();
+ (void) reset_signal_mask();
+ assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);
+
execlp("diff", "diff", "-us", "--", bottom, top, NULL);
- log_error("Failed to execute diff: %m");
- _exit(1);
+ log_error_errno(errno, "Failed to execute diff: %m");
+ _exit(EXIT_FAILURE);
}
- wait_for_terminate_and_warn("diff", pid);
+ wait_for_terminate_and_warn("diff", pid, false);
putchar('\n');
return k;
if (errno == ENOENT)
return 0;
- log_error("Failed to open %s: %m", path);
+ log_error_errno(errno, "Failed to open %s: %m", path);
return -errno;
}
const char *word, *state;
size_t l;
- FOREACH_WORD(word, l, flag_str, state) {
+ FOREACH_WORD_SEPARATOR(word, l, flag_str, ",", state) {
if (strneq("masked", word, l))
flags |= SHOW_MASKED;
else if (strneq ("equivalent", word, l))
return 0;
case ARG_VERSION:
- puts(PACKAGE_STRING);
- puts(SYSTEMD_FEATURES);
- return 0;
+ return version();
case ARG_NO_PAGER:
arg_no_pager = true;