Re: Any chainloading program to call prctl(PR_SET_PDEATHSIG, signal)

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Thu, 12 Oct 2023 02:15:17 +0000

>It turns out there is this Linux specific syscall (prctl(PR_SET_PDEATHSIG, signal)) to set the saner behavior of actually being informed if your parent dies and react to it so s6 is able to bring service back up, but it’s opt-in. Is there any tool in the s6 ecosystem or otherwise that I can use to call it before exec’ing to the service itself? I couldn’t find in s6-linux-utils and I would guess it’s not part of the portable tools, being Linux specific. Is there a portable equivalent? Is there any interest in receiving a patch, alternatively?

  The short answer is: no, not yet, sorry.

  The long answer is: prctl is complicated, and I do intend to do
something with it in the long run because there are useful things in
there, but it requires thought and planning. Typically, what I'd want
is to check what functionality is available on other systems than Linux
and how reasonably easy it is to implement, then add that functionality
as part of a portable program suite, and add the rest, or a useful
subset
of, as part of s6-linux-utils or something.

  Also, I'd like to see whether there isn't a better abstraction level
than blindly implementing all the options and flags in prctl. So, I
don't want to rush this, especially not while focused on other things.

  For your use case, however, you can certainly implement a
prctl(PR_SET_PDEATHSIG, SIGTERM) wrapper yourself, that doesn't sound
difficult. Or you could use cgroups: have your run script put itself
in a dedicated process cgroup, and a finish script ensure that all the
processes in the cgroup are killed when the service goes down.

--
  Laurent
Received on Thu Oct 12 2023 - 04:15:17 CEST

This archive was generated by hypermail 2.4.0 : Thu Oct 12 2023 - 04:15:46 CEST