On Fri, May 27, 2016 at 8:04 AM, Tom Hughes <t...@compton.nu> wrote:
> On 27/05/16 15:48, Zbigniew Jędrzejewski-Szmek wrote:
>> On Fri, May 27, 2016 at 03:26:45PM +0100, Tom Hughes wrote:
>>
>>> Which works fine except that the scope remains even after the screen
>>> has exited...
>>
>> Hm, it shouldn't I think. Seems to work fine here. How
>> are you running the command and what exactly remains behind?
>
> So I'm trying this in F23 currently, so F24 might be different, but basically 
> I did:
>
> systemd-run --scope --user /bin/screen
>
> and got a scope like this:
>
> % systemctl --user status run-17952.scope
> ● run-17952.scope - /bin/screen
>    Loaded: loaded (/run/user/2067/systemd/user/run-17952.scope; static; 
> vendor preset: enabled)
>   Drop-In: /run/user/2067/systemd/user/run-17952.scope.d
>            └─50-Description.conf
>    Active: active (running) since Fri 2016-05-27 16:01:41 BST; 33s ago
>    CGroup: /user.slice/user-2067.slice/user@2067.service/run-17952.scope
>            ├─17952 /bin/screen
>            ├─17953 /bin/SCREEN
>            └─17954 /bin/zsh
>
> then hit ctrl-D to exit screen and was left with:
>
> % systemctl --user status run-17952.scope
> ● run-17952.scope - /bin/screen
>    Loaded: loaded (/run/user/2067/systemd/user/run-17952.scope; static; 
> vendor preset: enabled)
>   Drop-In: /run/user/2067/systemd/user/run-17952.scope.d
>            └─50-Description.conf
>    Active: active (running) since Fri 2016-05-27 16:01:41 BST; 39s ago
>
> Tom

Either the scope code is buggy or has IMO very strange behavior:

$ systemd-run --user --scope echo foo
Running scope as unit run-4980.scope.
foo

$ systemctl --user status run-4980.scope
● run-4980.scope - /usr/bin/echo foo
   Loaded: loaded (/run/user/1000/systemd/user/run-4980.scope; static;
vendor preset: enabled)
  Drop-In: /run/user/1000/systemd/user/run-4980.scope.d
           └─50-Description.conf
   Active: active (running) since Fri 2016-05-27 08:16:03 PDT; 14s ago

Shouldn't the default be to remove the scope when all its processes
are gone?  The manpage for systemd-run says:

       --remain-after-exit
           After the service or scope process has terminated, keep the service
           around until it is explicitly stopped. This is useful to collect
           runtime information about the service after it finished running.
           Also see RemainAfterExit= in systemd.service(5).

and I did *not* set that flag.  At the very least, the manpage
description of --scope should IMO be improved and the recommendation
to use it for long-running processes should be reconsidered.

Now let's try the service mode:

$ systemctl status --user run-5457.service
● run-5457.service - /bin/sleep 30
   Loaded: loaded (/run/user/1000/systemd/user/run-5457.service;
static; vendor preset: enabled)
  Drop-In: /run/user/1000/systemd/user/run-5457.service.d
           └─50-Description.conf, 50-ExecStart.conf
   Active: active (running) since Fri 2016-05-27 08:24:03 PDT; 5s ago
 Main PID: 5458 (sleep)
   CGroup: /user.slice/user-1000.slice/user@1000.service/run-5457.service
           └─5458 /bin/sleep 30

Then, after a while:

$ systemctl status --user run-5457.service
● run-5457.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


Meanwhile, it's entirely unclear to me whether --scope will allow
screen to survive past when all user sessions are logged out and how
this interacts with "linger".  The linger docs are not very good IMO.


Anyway, ISTM the best fix would be for tmux and screen to learn how to
start *services* (not scopes) when they start a whole new session.

--Andy
--
devel mailing list
devel@lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/devel@lists.fedoraproject.org

Reply via email to