Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #242330

Re: How to cause a process started in .xsessionrc to terminate with x-session termination?

From Greg Wooledge <greg@wooledge.org>
Newsgroups linux.debian.user
Subject Re: How to cause a process started in .xsessionrc to terminate with x-session termination?
Date 2021-11-22 17:50 +0100
Message-ID <DmkFX-1p4-1@gated-at.bofh.it> (permalink)
References (3 earlier) <DlgXM-4q7-3@gated-at.bofh.it> <DlFt9-248-19@gated-at.bofh.it> <DlFW9-2sS-1@gated-at.bofh.it> <Dmjqx-Ko-1@gated-at.bofh.it> <DmjTA-TP-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Nov 22, 2021 at 10:58:28AM -0500, Greg Wooledge wrote:
> (Unless someone can figure out how to make systemd do this.)

Google found <https://wiki.archlinux.org/title/systemd/User> which
is the first time I've ever seen an attempt at an end user's guide
for systemd --user services.

So, I decided to play with this a little bit.

I've got a user account named "tester" which is normally not logged in,
and which had no running processes at the time I began testing.

I used "su - tester" to open a shell as this user.  This did *not* bring
up a systemd --user service manager.  Apparently "su -" does not count
as a login session for that purpose.

Based on the Arch wiki page, I created a .config/systemd/user directory,
and then created this file inside it:

----------------------------------------------------------------
tester@unicorn:~/.config/systemd/user$ cat sleeper.service 
[Unit]
Description=Sleep command for testing

[Service]
ExecStart=/bin/sleep 12345

[Install]
WantedBy=default.target
----------------------------------------------------------------

Of course, I couldn't enable it (at least not via the normal systemctl
route) because there was no --user manager running as "tester" yet.

Next, I pressed Ctrl-Alt-F2 to get to a console terminal, and logged in
as tester.  This brought up the systemd --user manager process.  After
that I was able to enable and start the sleeper.service unit.

I logged out of the tty2 shell, and pressed Ctrl-Alt-F1 to get back to
my X session running as greg.  Then I checked the processes running as
user tester:

----------------------------------------------------------------
unicorn:~$ ps -fu tester
UID          PID    PPID  C STIME TTY          TIME CMD
tester   1604310       1  0 11:18 ?        00:00:00 /lib/systemd/systemd --user
tester   1604311 1604310  0 11:18 ?        00:00:00 (sd-pam)
tester   1604330 1604310  0 11:18 ?        00:00:00 /usr/bin/pipewire
tester   1604335 1604310  0 11:18 ?        00:00:00 /usr/bin/dbus-daemon --sessi
tester   1604336 1604330  0 11:18 ?        00:00:00 /usr/bin/pipewire-media-sess
tester   1604363 1604310  0 11:18 ?        00:00:00 /bin/sleep 12345
----------------------------------------------------------------

I spent a few seconds reading this, and wondering what on earth a "pipewire"
is.  I checked to see if I was running one as "greg":

----------------------------------------------------------------
unicorn:~$ ps -ef | grep pipewire
greg         849     829  0 Oct09 ?        00:00:00 /usr/bin/pipewire
greg         861     849  0 Oct09 ?        00:00:14 /usr/bin/pipewire-media-session
greg     1604399   66960  0 11:19 pts/31   00:00:00 grep pipewire
----------------------------------------------------------------

The pipewire running as "tester" was... gone?  I checked again:

----------------------------------------------------------------
unicorn:~$ ps -fu tester
UID          PID    PPID  C STIME TTY          TIME CMD
----------------------------------------------------------------

So, it seems that the sleeper.service which was started under the
management of the systemd --user process *did* get killed.  Not
immediately, but within a minute or so.

I opened another "su - tester" session, and ran this to check for more
details:

----------------------------------------------------------------
tester@unicorn:~/.config/systemd/user$ journalctl --user -u sleeper
-- Journal begins at Mon 2021-11-22 11:18:09 EST, ends at Mon 2021-11-22 11:19:>
Nov 22 11:18:27 unicorn systemd[1604310]: Started Sleep command for testing.
Nov 22 11:19:00 unicorn systemd[1604310]: Stopping Sleep command for testing...
Nov 22 11:19:00 unicorn systemd[1604310]: sleeper.service: Succeeded.
Nov 22 11:19:00 unicorn systemd[1604310]: Stopped Sleep command for testing.
----------------------------------------------------------------

I don't know the exact time that I closed the login shell on tty2.  It
*could* have been at exactly 11:19:00 but that seems like a suspiciously
round number (and a suspiciously long time after I started the service).
Also:

----------------------------------------------------------------
unicorn:~$ last
tester   tty2                          Mon Nov 22 11:18 - 11:18  (00:00)
[...]
----------------------------------------------------------------

Maybe there's something that triggers every minute and cleans up
logged-out user units?  I don't know.

That's as far as I got.  If the OP wants to try writing a systemd --user
unit file for their unison thingy, and see if that starts and stops in
a way that they find acceptable, that would be a cool experiment.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to cause a process started in .xsessionrc to terminate with  x-session termination? Arkadiusz Dabrowski <ardabro@gmail.com> - 2021-11-17 22:40 +0100
  Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-17 23:10 +0100
  Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Brian <ad44@cityscape.co.uk> - 2021-11-18 00:50 +0100
  Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-18 14:10 +0100
  Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? songbird <songbird@anthive.com> - 2021-11-18 14:10 +0100
  Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? David Wright <deblis@lionunicorn.co.uk> - 2021-11-18 21:40 +0100
    Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-18 21:50 +0100
      Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Jonathan Dowland <jon+debian-user@dow.land> - 2021-11-18 22:30 +0100
        Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-18 23:00 +0100
          Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Arkadiusz Dabrowski <ardabro@gmail.com> - 2021-11-18 23:10 +0100
      Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Brian <ad44@cityscape.co.uk> - 2021-11-19 19:40 +0100
        Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Arkadiusz Dabrowski <ardabro@gmail.com> - 2021-11-20 21:50 +0100
          Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-20 22:20 +0100
            Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Arkadiusz Dabrowski <ardabro@gmail.com> - 2021-11-21 19:20 +0100
              Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-21 20:20 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Arkadiusz Dabrowski <ardabro@gmail.com> - 2021-11-21 20:50 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? David Wright <deblis@lionunicorn.co.uk> - 2021-11-22 06:50 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-22 13:40 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? David Wright <deblis@lionunicorn.co.uk> - 2021-11-22 21:50 +0100
            Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Musbur <musbur@posteo.org> - 2021-11-22 16:30 +0100
              Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-22 17:00 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-22 17:50 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Jonathan Dowland <jon+debian-user@dow.land> - 2021-11-23 13:10 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-23 14:00 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? David Wright <deblis@lionunicorn.co.uk> - 2021-11-23 16:30 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Andrei POPESCU <andreimpopescu@gmail.com> - 2021-12-10 14:40 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Andrei POPESCU <andreimpopescu@gmail.com> - 2021-12-10 15:10 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? David Wright <deblis@lionunicorn.co.uk> - 2021-11-22 21:50 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Greg Wooledge <greg@wooledge.org> - 2021-11-22 22:20 +0100
                Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? David Wright <deblis@lionunicorn.co.uk> - 2021-11-23 16:30 +0100
    Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Jonathan Dowland <jon+debian-user@dow.land> - 2021-11-18 22:30 +0100
  Re: How to cause a process started in .xsessionrc to terminate with  x-session termination? Mark Neyhart <Mark.Neyhart@akleg.gov> - 2021-11-18 22:20 +0100

csiph-web