[systemd-devel] killmode

Pascal patatetom at gmail.com
Fri May 20 19:03:12 UTC 2022


will try in this way.
thanks for feedback.

regards, lacsaP.

Le ven. 20 mai 2022 à 19:38, Mike Gilbert <floppym at gentoo.org> a écrit :

> On Fri, May 20, 2022 at 1:34 PM Mike Gilbert <floppym at gentoo.org> wrote:
> >
> > On Fri, May 20, 2022 at 12:54 PM Pascal <patatetom at gmail.com> wrote:
> > >
> > > not really in the sense that qemu-nbd launches and immediately gives
> the hand back to the script that called it.
> > > the script ends positively and qemu-nbd is killed by systemd because
> it is considered to be garbage left behind by the script.
> > > this is not quite the case of a timeout that systemd terminates, but
> the result is the same.
> > > in this case, qemu-nbd looks more like a daemon.
> > >
> > > I was wondering if there was a way to propagate the killmode through a
> udev rule that starts a script (like a service)... but it seems from the
> documentation that the answer is no :-(
> > >
> > > """In order to activate long-running processes from udev rules,
> provide a service unit and pull it in from a udev device using the
> SYSTEMD_WANTS device property. See systemd.device(5) for details."""
> > > I would appreciate (and maybe I won't be the only one) a concrete
> example based, for example,  on my problem ;-)
> > >
> > > let's just say that my rule is :
> > >
> > > KERNEL=="sdb", RUN+="/usr/local/sbin/myscript"
> > >
> > > and my script is :
> > >
> > > #!/usr/bin/bash
> > > qemu-nbd -r -s -f raw -c /dev/nbd0 /dev/sdb
> >
> > The most direct translation would be something like this:
> >
> > qemu-nbd0-sdb.service:
> > [Service]
> > ExecStart=qemu-nbd -r -s -f raw -c /dev/nbd0 /dev/sdb
> >
> > udev rule:
> > KERNEL=="sdb", ENV{SYSTEMD_WANTS}+="qemu-nbd0-sdb.service"
>
> Oh, you'll want to add Type=forking to the .service file if it always
> forks a child and exits.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220520/d77a15c8/attachment.htm>


More information about the systemd-devel mailing list