Re: [systemd-devel] systemd reboot problem

2017-03-31 Thread Jérémy Rosen
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 " 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 

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

Facebook  Google%2B 
 LinkedIn 
 Twitter 




bandeaux_mail 



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


Re: [systemd-devel] systemd reboot problem

2017-03-30 Thread Lennart Poettering
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

-- 
Lennart Poettering, Red Hat
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd reboot problem

2017-03-07 Thread Brian Kroth
In that case, you could also just do something like this:
# for i in {u,s,b}; do echo $i > /proc/sysrq-trigger; done
For "Remount read-only, Sync, (re)Boot".  There are also hotkey sequences
to do that (the modern equivalent of the three fingered salute) which might
be more appropriate in the case of a hanging reboot.  Have a look at the
dmesg output of "echo ? > /proc/sysrq-trigger" or the sysrq-trigger info in
the kernel documentation for other info.

Cheers,
Brian

On Tue, Mar 7, 2017 at 1:31 PM David Strauss  wrote:

> > But I don't want to wait for those services to shutdown.
>
> Then there's no reason to interact with systemd if you want to force an
> immediate, unclean reboot. You just want something like the reboot syscall
> with LINUX_REBOOT_CMD_RESTART.
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd reboot problem

2017-03-07 Thread David Strauss
> But I don't want to wait for those services to shutdown.

Then there's no reason to interact with systemd if you want to force an
immediate, unclean reboot. You just want something like the reboot syscall
with LINUX_REBOOT_CMD_RESTART.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] systemd reboot problem

2017-03-06 Thread lin webber
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.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel