Note that if you are calling from C code, you might want to call it
through the Dbus API, rather than the "system" system call.
As for debugging what blocks the shutdown, here are a few clues
* does "systemctl reboot -f" stop the system correctly ?
if yes, one of your daemons is blocking the shutdown, check all the
printed logs for a "Stopping XXXX" with no corresponding "Stoped XXX"
try stopping manually that service and debug what's going on with it
* does "systemctl reboot -f -f" stop shut down the system (this will not
unmount correctly the filesystems and is only for debugging purpose)
if that does not stop the system, your problem is at the
kernel/hardware level. More specifically, your kernel does not know how
to turn the power off on your system.
Jérémy
On 30/03/2017 10:47, Lennart Poettering wrote:
On Tue, 07.03.17 03:15, lin webber (webber...@outlook.com) wrote:
I use “system("reboot")” in my C program and system does not shutdown.I think
that systemd is waiting for some services to shutdown which can't shutdown immediately.
But I don't want to wait for those services to shutdown.How can I shutdown my
system immediately in my C program.which API should I call?
Thank you for reply.
There are several ways to reboot your system:
1) use the raw reboot() syscall. In this case file systems might end
up being dirty, and some more complex daemons might not like it
either.
2) Use "systemctl reboot -ff", which is pretty much the same as #1,
but accessible from the shell.
3) Use "systemctl reboot -f", which is a slightly friendlier version
than the above. In this mode, systemd won't bother with stopping
services correctly (instead it will just SIGTERM them all and
SIGKILL what is left then). However it will still place all file
systems in a clean state before issuing reboot().
4) Use "systemctl reboot", which is the friendliest version and
correctly shuts down all services, i.e. is equivalent to plain
"reboot" the way you already tried.
Unless you have a completely stateless system with all file systems
either read-only or formatted on each boot #3 is the vastly better
option than #1/#2.
Lennart
--
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
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel