mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-12-20 13:36:39 +07:00
dbus: complete exec status coverage
This commit is contained in:
parent
14ad1d1437
commit
b58b41160f
@ -26,6 +26,13 @@
|
||||
|
||||
#include "manager.h"
|
||||
|
||||
#define BUS_EXEC_STATUS_INTERFACE(prefix) \
|
||||
" <property name=\"" prefix "StartTimestamp\" type=\"t\" access=\"read\"/>\n" \
|
||||
" <property name=\"" prefix "ExitTimestamp\" type=\"t\" access=\"read\"/>\n" \
|
||||
" <property name=\"" prefix "PID\" type=\"u\" access=\"read\"/>\n" \
|
||||
" <property name=\"" prefix "Code\" type=\"i\" access=\"read\"/>\n" \
|
||||
" <property name=\"" prefix "Status\" type=\"i\" access=\"read\"/>\n"
|
||||
|
||||
#define BUS_EXEC_CONTEXT_INTERFACE \
|
||||
" <property name=\"Environment\" type=\"as\" access=\"read\"/>\n" \
|
||||
" <property name=\"UMask\" type=\"u\" access=\"read\"/>\n" \
|
||||
@ -130,6 +137,13 @@
|
||||
{ interface, "PrivateTmp", bus_property_append_bool, "b", &(context).private_tmp }, \
|
||||
{ interface, "NoSetSID", bus_property_append_bool, "b", &(context).no_setsid }
|
||||
|
||||
#define BUS_EXEC_STATUS_PROPERTIES(interface, estatus, prefix) \
|
||||
{ interface, prefix "StartTimestamp", bus_property_append_usec, "t", &(estatus).start_timestamp.realtime }, \
|
||||
{ interface, prefix "ExitTimestamp", bus_property_append_usec, "t", &(estatus).start_timestamp.realtime }, \
|
||||
{ interface, prefix "PID", bus_property_append_pid, "u", &(estatus).pid }, \
|
||||
{ interface, prefix "Code", bus_property_append_int, "i", &(estatus).code }, \
|
||||
{ interface, prefix "Status", bus_property_append_int, "i", &(estatus).status }
|
||||
|
||||
int bus_execute_append_output(Manager *m, DBusMessageIter *i, const char *property, void *data);
|
||||
int bus_execute_append_input(Manager *m, DBusMessageIter *i, const char *property, void *data);
|
||||
int bus_execute_append_oom_adjust(Manager *m, DBusMessageIter *i, const char *property, void *data);
|
||||
|
@ -38,6 +38,7 @@
|
||||
" <property name=\"RootDirectoryStartOnly\" type=\"b\" access=\"read\"/>\n" \
|
||||
" <property name=\"ValidNoProcess\" type=\"b\" access=\"read\"/>\n" \
|
||||
" <property name=\"KillMode\" type=\"s\" access=\"read\"/>\n" \
|
||||
BUS_EXEC_STATUS_INTERFACE("ExecMain") \
|
||||
" <property name=\"MainPID\" type=\"u\" access=\"read\"/>\n" \
|
||||
" <property name=\"ControlPID\" type=\"u\" access=\"read\"/>\n" \
|
||||
" <property name=\"SysVStartPriority\" type=\"i\" access=\"read\"/>\n" \
|
||||
@ -77,7 +78,7 @@ DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connectio
|
||||
{ "org.freedesktop.systemd1.Service", "RootDirectoryStartOnly", bus_property_append_bool, "b", &u->service.root_directory_start_only },
|
||||
{ "org.freedesktop.systemd1.Service", "ValidNoProcess", bus_property_append_bool, "b", &u->service.valid_no_process },
|
||||
{ "org.freedesktop.systemd1.Service", "KillMode", bus_unit_append_kill_mode, "s", &u->service.kill_mode },
|
||||
/* MainExecStatus */
|
||||
BUS_EXEC_STATUS_PROPERTIES("org.freedesktop.systemd1.Service", u->service.main_exec_status, "ExecMain"),
|
||||
{ "org.freedesktop.systemd1.Service", "MainPID", bus_property_append_pid, "u", &u->service.main_pid },
|
||||
{ "org.freedesktop.systemd1.Service", "ControlPID", bus_property_append_pid, "u", &u->service.control_pid },
|
||||
{ "org.freedesktop.systemd1.Service", "SysVPath", bus_property_append_string, "s", u->service.sysv_path },
|
||||
|
@ -1281,8 +1281,7 @@ int exec_spawn(ExecCommand *command,
|
||||
|
||||
log_debug("Forked %s as %lu", command->path, (unsigned long) pid);
|
||||
|
||||
command->exec_status.pid = pid;
|
||||
dual_timestamp_get(&command->exec_status.start_timestamp);
|
||||
exec_status_start(&command->exec_status, pid);
|
||||
|
||||
*ret = pid;
|
||||
return 0;
|
||||
@ -1561,9 +1560,21 @@ void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
|
||||
}
|
||||
}
|
||||
|
||||
void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status) {
|
||||
void exec_status_start(ExecStatus *s, pid_t pid) {
|
||||
assert(s);
|
||||
|
||||
zero(*s);
|
||||
s->pid = pid;
|
||||
dual_timestamp_get(&s->start_timestamp);
|
||||
}
|
||||
|
||||
void exec_status_exit(ExecStatus *s, pid_t pid, int code, int status) {
|
||||
assert(s);
|
||||
|
||||
if ((s->pid && s->pid != pid) ||
|
||||
!s->start_timestamp.realtime <= 0)
|
||||
zero(*s);
|
||||
|
||||
s->pid = pid;
|
||||
dual_timestamp_get(&s->exit_timestamp);
|
||||
|
||||
|
@ -217,7 +217,8 @@ void exec_context_init(ExecContext *c);
|
||||
void exec_context_done(ExecContext *c);
|
||||
void exec_context_dump(ExecContext *c, FILE* f, const char *prefix);
|
||||
|
||||
void exec_status_fill(ExecStatus *s, pid_t pid, int code, int status);
|
||||
void exec_status_start(ExecStatus *s, pid_t pid);
|
||||
void exec_status_exit(ExecStatus *s, pid_t pid, int code, int status);
|
||||
void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix);
|
||||
|
||||
const char* exec_output_to_string(ExecOutput i);
|
||||
|
@ -936,7 +936,7 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
m->failure = m->failure || !success;
|
||||
|
||||
if (m->control_command) {
|
||||
exec_status_fill(&m->control_command->exec_status, pid, code, status);
|
||||
exec_status_exit(&m->control_command->exec_status, pid, code, status);
|
||||
m->control_command = NULL;
|
||||
m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
|
||||
}
|
||||
|
@ -144,6 +144,8 @@ static int service_set_main_pid(Service *s, pid_t pid) {
|
||||
s->main_pid = pid;
|
||||
s->main_pid_known = true;
|
||||
|
||||
exec_status_start(&s->main_exec_status, pid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2082,7 +2084,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
|
||||
if (s->main_pid == pid) {
|
||||
|
||||
exec_status_fill(&s->main_exec_status, pid, code, status);
|
||||
exec_status_exit(&s->main_exec_status, pid, code, status);
|
||||
s->main_pid = 0;
|
||||
|
||||
if (s->type != SERVICE_FORKING) {
|
||||
@ -2138,7 +2140,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
} else if (s->control_pid == pid) {
|
||||
|
||||
if (s->control_command)
|
||||
exec_status_fill(&s->control_command->exec_status, pid, code, status);
|
||||
exec_status_exit(&s->control_command->exec_status, pid, code, status);
|
||||
|
||||
s->control_pid = 0;
|
||||
|
||||
|
@ -1397,7 +1397,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
s->failure = s->failure || !success;
|
||||
|
||||
if (s->control_command)
|
||||
exec_status_fill(&s->control_command->exec_status, pid, code, status);
|
||||
exec_status_exit(&s->control_command->exec_status, pid, code, status);
|
||||
|
||||
log_debug("%s control process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user