chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-rtnl: extend type system to allow address-family to decide the union members
[elogind.git]
/
src
/
journal
/
coredumpctl.c
diff --git
a/src/journal/coredumpctl.c
b/src/journal/coredumpctl.c
index 2163ef998941a95d09b0ee337b27996614e570c9..afb39ad035cb871e67b99e9f423821542bd59c2d 100644
(file)
--- a/
src/journal/coredumpctl.c
+++ b/
src/journal/coredumpctl.c
@@
-26,8
+26,7
@@
#include <fcntl.h>
#include <unistd.h>
#include <fcntl.h>
#include <unistd.h>
-#include "systemd/sd-journal.h"
-
+#include "sd-journal.h"
#include "build.h"
#include "set.h"
#include "util.h"
#include "build.h"
#include "set.h"
#include "util.h"
@@
-38,6
+37,7
@@
#include "journal-internal.h"
#include "copy.h"
#include "compress.h"
#include "journal-internal.h"
#include "copy.h"
#include "compress.h"
+#include "sigbus.h"
static enum {
ACTION_NONE,
static enum {
ACTION_NONE,
@@
-50,8
+50,7
@@
static const char* arg_field = NULL;
static int arg_no_pager = false;
static int arg_no_legend = false;
static int arg_one = false;
static int arg_no_pager = false;
static int arg_no_legend = false;
static int arg_one = false;
-
-static FILE* output = NULL;
+static FILE* arg_output = NULL;
static Set *new_matches(void) {
Set *set;
static Set *new_matches(void) {
Set *set;
@@
-184,16
+183,14
@@
static int parse_argv(int argc, char *argv[], Set *matches) {
break;
case 'o':
break;
case 'o':
- if (output) {
+ if (
arg_
output) {
log_error("cannot set output more than once");
return -EINVAL;
}
log_error("cannot set output more than once");
return -EINVAL;
}
- output = fopen(optarg, "we");
- if (!output) {
- log_error_errno(errno, "writing to '%s': %m", optarg);
- return -errno;
- }
+ arg_output = fopen(optarg, "we");
+ if (!arg_output)
+ return log_error_errno(errno, "writing to '%s': %m", optarg);
break;
break;
@@
-609,10
+606,8
@@
static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
return log_oom();
fdt = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
return log_oom();
fdt = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
- if (fdt < 0) {
- log_error_errno(errno, "Failed to create temporary file: %m");
- return -errno;
- }
+ if (fdt < 0)
+ return log_error_errno(errno, "Failed to create temporary file: %m");
log_debug("Created temporary file %s", temp);
fd = fdt;
log_debug("Created temporary file %s", temp);
fd = fdt;
@@
-691,14
+686,14
@@
static int dump_core(sd_journal* j) {
if (r < 0)
return r;
if (r < 0)
return r;
- print_info(output ? stdout : stderr, j, false);
+ print_info(
arg_
output ? stdout : stderr, j, false);
- if (on_tty() && !output) {
+ if (on_tty() && !
arg_
output) {
log_error("Refusing to dump core to tty.");
return -ENOTTY;
}
log_error("Refusing to dump core to tty.");
return -ENOTTY;
}
- r = save_core(j,
output ? fileno(
output) : STDOUT_FILENO, NULL, NULL);
+ r = save_core(j,
arg_output ? fileno(arg_
output) : STDOUT_FILENO, NULL, NULL);
if (r < 0)
return log_error_errno(r, "Coredump retrieval failed: %m");
if (r < 0)
return log_error_errno(r, "Coredump retrieval failed: %m");
@@
-807,6
+802,8
@@
int main(int argc, char *argv[]) {
if (arg_action == ACTION_NONE)
goto end;
if (arg_action == ACTION_NONE)
goto end;
+ sigbus_install();
+
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
if (r < 0) {
log_error_errno(r, "Failed to open journal: %m");
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
if (r < 0) {
log_error_errno(r, "Failed to open journal: %m");
@@
-825,7
+822,7
@@
int main(int argc, char *argv[]) {
}
}
}
}
- if (_unlikely_(log_get_max_level() >= LOG_
PRI(LOG_DEBUG)
)) {
+ if (_unlikely_(log_get_max_level() >= LOG_
DEBUG
)) {
_cleanup_free_ char *filter;
filter = journal_make_match_string(j);
_cleanup_free_ char *filter;
filter = journal_make_match_string(j);
@@
-857,8
+854,8
@@
int main(int argc, char *argv[]) {
end:
pager_close();
end:
pager_close();
- if (output)
- fclose(output);
+ if (
arg_
output)
+ fclose(
arg_
output);
return r >= 0 ? r : EXIT_FAILURE;
}
return r >= 0 ? r : EXIT_FAILURE;
}