From ae572acd62fe80bbcf242e02e4947900682ded16 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 28 Feb 2017 17:55:57 +0100 Subject: core: always consider clients that pinned a unit to be subscribers If a client pins a unit, then it makes sense to also implicitly make it a subscriber. This is useful for clients that just want to watch one specific unit: they can pin it and receive its messages. --- src/core/dbus-unit.c | 4 ++-- src/core/unit.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index f1306a023f..f15bb2196c 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -1131,7 +1131,7 @@ void bus_unit_send_change_signal(Unit *u) { if (!u->id) return; - r = bus_foreach_bus(u->manager, NULL, u->sent_dbus_new_signal ? send_changed_signal : send_new_signal, u); + r = bus_foreach_bus(u->manager, u->bus_track, u->sent_dbus_new_signal ? send_changed_signal : send_new_signal, u); if (r < 0) log_unit_debug_errno(u, r, "Failed to send unit change signal for %s: %m", u->id); @@ -1177,7 +1177,7 @@ void bus_unit_send_removed_signal(Unit *u) { if (!u->id) return; - r = bus_foreach_bus(u->manager, NULL, send_removed_signal, u); + r = bus_foreach_bus(u->manager, u->bus_track, send_removed_signal, u); if (r < 0) log_unit_debug_errno(u, r, "Failed to send unit remove signal for %s: %m", u->id); } diff --git a/src/core/unit.c b/src/core/unit.c index 174dd42819..b091a0999b 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -402,6 +402,7 @@ void unit_add_to_dbus_queue(Unit *u) { /* Shortcut things if nobody cares */ if (sd_bus_track_count(u->manager->subscribed) <= 0 && + sd_bus_track_count(u->bus_track) <= 0 && set_isempty(u->manager->private_buses)) { u->sent_dbus_new_signal = true; return; -- cgit v1.2.3-54-g00ecf From a625def6ea3e6fb1ad78f40a9ff4454c4da79aca Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 28 Feb 2017 18:27:42 +0100 Subject: run: also pin unit when we we are in --pty mode Since 95f1d6bfecde60b245fae1ab0313b550201e7880 we'll subscribe to unit signals to figure out when to disconnect the pty. But that can only work correctly if we actually subscribe to the unit's signals. Hence, explicitly pin (and thus subscribe to) the unit we just created not only in --wait mode but also in --pty mode. Or to say this differently: we need to pin the unit in the same cases as we install the signal match. 95f1d6bfecde60b245fae1ab0313b550201e7880 forgot to do that. This is relevant to make sure systemd-run works correctly in --user mode, and correctly exits when the spawned service dies. To test: systemd-run --user -t /bin/bash And then press ^D. This will hang before this change, but exit cleanly after it. --- src/run/run.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/run/run.c b/src/run/run.c index f8257abc93..2e6765aa18 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -497,7 +497,7 @@ static int transient_service_set_properties(sd_bus_message *m, char **argv, cons if (r < 0) return r; - if (arg_wait) { + if (arg_wait || arg_pty) { r = sd_bus_message_append(m, "(sv)", "AddRef", "b", 1); if (r < 0) return r; @@ -1026,7 +1026,6 @@ static int start_transient_service( pty_forward_set_handler(c.forward, pty_forward_handler, &c); } - path = unit_dbus_path_from_name(service); if (!path) return log_oom(); -- cgit v1.2.3-54-g00ecf