[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



On Mon 22 Nov 2021 at 07:31:04 (-0500), Greg Wooledge wrote:
> On Sun, Nov 21, 2021 at 11:39:53PM -0600, David Wright wrote:
> > On Sun 21 Nov 2021 at 14:16:26 (-0500), Greg Wooledge wrote:
> > > So then, it would look something like this:
> > > 
> > > your unison thing &
> > > unisonPID=$!
> > > other things you want to run
> > > magic MATE start command
> > > kill "$unisonPID"
> > 

¶A
> > I expect that DEs have DontZap set, so that they get a chance to clean
> > up after themselves. (That's just a guess. I have no idea how X
> > servers, DEs and DMs interact with each other.)
> > 

¶B
> > I think that my expectation in my earlier post might have been
> > unrealistic. If you don't map any sort of window, then I'm not sure
> > that falling out of .xsession would kill a background job. And
> > zapping the X server likely wouldn't get to the kill command above.
> 
> I'm not sure what you're saying here.  Are you expecting that the OP is
> going to "zap" the X server (by which I believe you mean pressing
> a magic key combination like Ctrl-Alt-Backspace, with an appropriate
> option set in the xorg.conf file to cause that to terminate the X server)
> rather than exiting from MATE in the normal manner?

When I wrote the post that ¶B refers to, the only evidence that the OP
was using a DE was mention of x-session-manager, which I've never seen
or used. Hence I overlooked it. So that post was written from the
viewpoint of startx, and I'm sure many users of startx terminate their
X server with C-A-B rather that exiting the WM. In my case, it's one
keystroke versus two well-aimed mouse clicks (and the latter assumes
that part of the root window is actually exposed), so you can guess
which way I choose.

> I'm expecting that the OP is exiting/logging out of MATE in whatever
> the normal way is.  Further I'm expecting that this normal logout
> action causes the "magic MATE start command" to terminate, returning
> control to the .xsession script.

As I wrote there, ¶A is a presumption that I have little chance of
confirming myself in the foreseeable future. (If it's untrue, I'd
expect someone would contradict and/or correct it pretty quickly.)

> We're not "falling out of .xsession" either.  It's just a shell script,
> so it works the way any other shell script works.  When the MATE session
> ends, the .xsession shell script moves on to the next command, which
> is kill.

So, back to ¶B; if you're not in the habit of putting exit 0 or return 0
at the end of every script, function, program, etc, that you write,
then most scripts you run can probably terminate by "falling out of
the end". (A counterexample would be FORTRAN X3.9-1966.)

I implied in my first post that a background job started in .xsession
would be killed when the X server terminated, be that by reaching the
end of the .xsession script (if you prefer that expression), or by
killing the X server (which abandons the rest of the .xsession script).
But I think this applies only if it maps a window, hence the need to
kill it, as shown in your example above, and absent from my post.

> > So it would seem common sense to use the GUI that unison provides,
> > even if the window was minimised or iconified (whatever is possible
> > while the program is still left running).
> 
> I know nothing about unison itself.

Nor I, beyond these lines from the Packages file (buster):

  Package: unison
  Description: file-synchronization tool for Unix and Windows

  Package: unison-gtk
  Description: file-synchronization tool for Unix and Windows with GTK+ interface
  Tag: admin::backup, admin::file-distribution, implemented-in::ocaml,
   interface::graphical, interface::x11, role::program, scope::utility,
   uitoolkit::gtk, uitoolkit::ncurses, use::synchronizing,
   x11::application

> That might work, but I can't confirm
> or deny it.  In either case, it doesn't appear to be what the OP wants.

No, but I don't let that constrain my thoughts on a topic. IANAI.
(I am not an intern.)

Cheers,
David.


Reply to: