I have no problem with changing some code in microupsd so it behave in certain
way. It is handling SIGTERM and other signals if needed.
The problem for me is that SIGTERM is send to process during system reboot and
system halt - so I need to differentiate between the two.
SIGTERM is sent, by default, to all processes early during shutdown.

You need to disable DefaultDependencies for your process to not recieve
the default SIGTERM and then trigger it yourself with the WandedBy that
was already described...

Your daemon is a late-shutdown daemon, not a normal daemon. I think
that deactivating default dependencies in this case makes sense.

I strongly advice carefully reading the section on default dependencies in
systemd.service, though... You will deactivate all default dependencies and
you probably don't want that. You'll need to manually reactivate the other
default dependencies

If you can suggest me  a way, maybe with some example I will change my code.

Best Regards

Normally services are given a certain amount of time to stop after SIGTERM
(or whatever KillSignal was set, or whatever ExecStop command was
specified). Even if microupsd doesn't handle SIGTERM nicely (which I'd call
a bug), it's possible to add some... arbitrary delays.

Units are stopped due to having automatic Conflicts=shutdown.target, if I
remember correctly. I'm not sure if disabling that default dependency is a
good approach though...

This time I can't think of a good combination that'd solve both problems
without introducing some ugly race conditions...

On Tue, Aug 8, 2017, 21:46 Marek Floriańczyk <marek.florianc...@gmail.com>

Dnia wtorek, 8 sierpnia 2017 21:04:18 CEST Andrei Borzenkov pisze:
08.08.2017 17:03, Marek Floriańczyk пишет:
What would be the proper way to distinguish between system is going

for reboot and for shutdown ?
Straightforward way is to make your service WantedBy poweroff.target and
halt.target. You can then have second service WantedBy reboot.target and
kexec.target. They may even call the same binary (script) but with
different arguments.
Thanks for answer,

So, my binary "microupsd" is started  by /etc/init.d/microups at the boot
to monitor power input, battery status etc.
During system halt I need to send SIGUSR1 to this "microupsd" process at
it will send command to microups device, moreover  I would like to give it
some time (like 1-2 seconds) to accomplish the transmission.
I don't need to send anything in case of reboot.

Should I prepare some script that sends SIGUSR1 to "microupsd" process and
then sleeps for 2 seconds and set it as WantedBy poweroff.target and
halt.target ?

How can I be sure that this script will be called before "microupsd" is
actually killed during system shutdown ?

Best Regards

systemd-devel mailing list

systemd-devel mailing list

Logo <http://www.smile.fr/>

20 rue des Jardins
92600 Asnières-sur-Seine
www.smile.fr <http://www.smile.fr/>       
*Jérémy ROSEN*
Architecte technique
Email : jeremy.ro...@smile.fr <mailto:jeremy.ro...@smile.fr>
Tel : +33141402967

Facebook <https://www.facebook.com/smileopensource> Google%2B <http://fr.slideshare.net/SmileOpenSource/presentations> LinkedIn <https://www.linkedin.com/company/smile> Twitter <https://twitter.com/GroupeSmile>

bandeaux_mail <http://www.smile.fr/Offres-services/Offres/Ingenierie?utm_source=signature&utm_medium=email&utm_campaign=signature>

eco Pour la planète, n'imprimez ce mail que si c'est nécessaire
systemd-devel mailing list

Reply via email to