mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
core: dump jobs list on sigrtmin+18 with 0x500
This commit is contained in:
parent
0213162743
commit
0112c37ce4
@ -24,6 +24,22 @@ void manager_dump_jobs(Manager *s, FILE *f, char **patterns, const char *prefix)
|
||||
}
|
||||
}
|
||||
|
||||
int manager_get_dump_jobs_string(Manager *m, char **patterns, const char *prefix, char **ret) {
|
||||
_cleanup_(memstream_done) MemStream ms = {};
|
||||
FILE *f;
|
||||
|
||||
assert(m);
|
||||
assert(ret);
|
||||
|
||||
f = memstream_init(&ms);
|
||||
if (!f)
|
||||
return -errno;
|
||||
|
||||
manager_dump_jobs(m, f, patterns, prefix);
|
||||
|
||||
return memstream_finalize(&ms, ret, NULL);
|
||||
}
|
||||
|
||||
void manager_dump_units(Manager *s, FILE *f, char **patterns, const char *prefix) {
|
||||
Unit *u;
|
||||
const char *t;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "manager.h"
|
||||
|
||||
void manager_dump_jobs(Manager *s, FILE *f, char **patterns, const char *prefix);
|
||||
int manager_get_dump_jobs_string(Manager *m, char **patterns, const char *prefix, char **ret);
|
||||
void manager_dump_units(Manager *s, FILE *f, char **patterns, const char *prefix);
|
||||
void manager_dump(Manager *s, FILE *f, char **patterns, const char *prefix);
|
||||
int manager_get_dump_string(Manager *m, char **patterns, char **ret);
|
||||
|
@ -3030,6 +3030,19 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
|
||||
manager_override_log_target(m, LOG_TARGET_NULL);
|
||||
break;
|
||||
|
||||
case MANAGER_SIGNAL_COMMAND_DUMP_JOBS: {
|
||||
_cleanup_free_ char *dump_jobs = NULL;
|
||||
|
||||
r = manager_get_dump_jobs_string(m, /* patterns= */ NULL, " ", &dump_jobs);
|
||||
if (r < 0) {
|
||||
log_warning_errno(errno, "Failed to acquire manager jobs dump: %m");
|
||||
break;
|
||||
}
|
||||
|
||||
log_dump(LOG_INFO, dump_jobs);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
generic = true;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "sd-device.h"
|
||||
#include "sd-event.h"
|
||||
|
||||
#include "common-signal.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "cgroup.h"
|
||||
#include "fdset.h"
|
||||
@ -23,6 +24,14 @@ typedef struct Unit Unit;
|
||||
/* Enforce upper limit how many names we allow */
|
||||
#define MANAGER_MAX_NAMES 131072 /* 128K */
|
||||
|
||||
/* On sigrtmin+18, private commands */
|
||||
enum {
|
||||
MANAGER_SIGNAL_COMMAND_DUMP_JOBS = _COMMON_SIGNAL_COMMAND_PRIVATE_BASE + 0,
|
||||
_MANAGER_SIGNAL_COMMAND_MAX,
|
||||
};
|
||||
|
||||
assert_cc((int) _MANAGER_SIGNAL_COMMAND_MAX <= (int) _COMMON_SIGNAL_COMMAND_PRIVATE_END);
|
||||
|
||||
typedef struct Manager Manager;
|
||||
|
||||
/* An externally visible state. We don't actually maintain this as state variable, but derive it from various fields
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
@ -48,6 +49,10 @@ enum {
|
||||
|
||||
COMMON_SIGNAL_COMMAND_MEMORY_PRESSURE = 0x300,
|
||||
COMMON_SIGNAL_COMMAND_MALLOC_INFO,
|
||||
|
||||
/* Private signals start at 0x500 */
|
||||
_COMMON_SIGNAL_COMMAND_PRIVATE_BASE = 0x500,
|
||||
_COMMON_SIGNAL_COMMAND_PRIVATE_END = 0xfff,
|
||||
};
|
||||
|
||||
struct sigrtmin18_info {
|
||||
|
Loading…
Reference in New Issue
Block a user