]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: also pin unit when we we are in --pty mode 5494/head
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Feb 2017 17:27:42 +0000 (18:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 28 Feb 2017 17:35:05 +0000 (18:35 +0100)
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

index f8257abc93b8b71dd07a5b8c32810198c0962929..2e6765aa188b4652c36e18d79d00223be91fe209 100644 (file)
@@ -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();