mirror of
https://github.com/troglobit/finit.git
synced 2026-11-03 13:28:27 +00:00
Change SIGUSR1 to be compatible with systemd and SysV init
This patch changes the behavior of SIGUSR1. Previously USR1 could be used to halt a running Finit system, similar to BusyBox init. However, compatibility with sysvinit and systemd has been deemed more important. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
3872077ff1
commit
53c7ddcb22
3 files changed
+34
-22
No files matched your search
+17
-9
@@ -12,28 +12,36 @@ have been adopted:
|
|||||||
Same effect as `finit q`, `init q`, or `initctl reload`, reloads all
|
Same effect as `finit q`, `init q`, or `initctl reload`, reloads all
|
||||||
*.conf files in `/etc/finit.d/`
|
*.conf files in `/etc/finit.d/`
|
||||||
|
|
||||||
|
This also restarts the API (initctl) socket, like SysV init and systemd
|
||||||
|
does on USR1 with their FIFO/D-Bus.
|
||||||
|
|
||||||
|
|
||||||
`SIGUSR1`
|
`SIGUSR1`
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Calls shutdown hooks, including `HOOK_SHUTDOWN`, stopping all running
|
Since Finit 4.1 this signal causes Finit to restart its API (initctl)
|
||||||
processes, and unmounts all file systems. Then tells kernel to halt.
|
socket, like SysV init and systemd does on USR1 with their FIFO/D-Bus.
|
||||||
Most people these days want `SIGUSR2` though.
|
|
||||||
|
Finit <= 4.0 performed a system halt (like USR2 without power-off), but
|
||||||
|
this caused compatibility problems with systemd and sysvinit on desktop
|
||||||
|
systems. Hence, since Finit 4.1 it is no longer possible to halt a
|
||||||
|
system with a signal.
|
||||||
|
|
||||||
SysV init and systemd use this to re-open their FIFO/D-Bus.
|
|
||||||
|
|
||||||
`SIGUSR2`
|
`SIGUSR2`
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Like SIGUSR1, but tell kernel to power-off the system, if ACPI or
|
Calls shutdown hooks, including `HOOK_SHUTDOWN`, stopping all running
|
||||||
similar exists to actually do this. If the kernel fails power-off,
|
processes, and unmounts all file systems. Then tells kernel to power
|
||||||
Finit falls back to halt.
|
off the system, if ACPI or similar exists to actually do this. If the
|
||||||
|
kernel fails power-off, Finit falls back to halt.
|
||||||
|
|
||||||
SysV init N/A, systemd dumps its internal state to log.
|
SysV init N/A, systemd dumps its internal state to log.
|
||||||
|
|
||||||
`SIGTERM`
|
`SIGTERM`
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Like `SIGUSR1`, but tell kernel to reboot the system when done.
|
Like `SIGUSR2`, but tell kernel to reboot the system when done.
|
||||||
|
|
||||||
SysV init N/A, systemd rexecutes itself.
|
SysV init N/A, systemd rexecutes itself.
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -206,7 +206,7 @@ int reboot_main(int argc, char *argv[])
|
|||||||
|
|
||||||
case CMD_HALT:
|
case CMD_HALT:
|
||||||
if (do_halt(NULL))
|
if (do_halt(NULL))
|
||||||
do_kill(SIGUSR1, msg);
|
do_kill(SIGUSR2, msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_POWEROFF:
|
case CMD_POWEROFF:
|
||||||
|
|||||||
@@ -31,21 +31,24 @@
|
|||||||
* does on USR1 with their FIFO/D-Bus.
|
* does on USR1 with their FIFO/D-Bus.
|
||||||
*
|
*
|
||||||
* SIGUSR1
|
* SIGUSR1
|
||||||
* Calls shutdown hooks, including HOOK_SHUTDOWN, stops all running
|
* Restarts API (initctl) socket, like SysV init and systemd does
|
||||||
* processes, and unmounts all file systems. Then tells kernel to
|
* on USR1 with their FIFO/D-Bus.
|
||||||
* halt. Most people these days want SIGUSR2 though.
|
|
||||||
*
|
*
|
||||||
* (SysV init and systemd use this to re-open their FIFO/D-Bus.)
|
* Finit <= 4.0 used to perform a system halt on USR1. This caused
|
||||||
|
* some quite nasty problems on systems with both systemd/sysvinit
|
||||||
|
* installed alongside finit. For compatibility reasons Finit 4.1
|
||||||
|
* changed to partial SIGHUP (api_exit/init).
|
||||||
*
|
*
|
||||||
* SIGUSR2
|
* SIGUSR2
|
||||||
* Like SIGUSR1, but tell kernel to power-off the system, if ACPI
|
* Calls shutdown hooks, including HOOK_SHUTDOWN, stops all running
|
||||||
* or similar exists to actually do this. If the kernel fails
|
* processes, and unmounts all file systems. Then tells kernel to
|
||||||
* power-off, Finit falls back to halt.
|
* power-off the system, if ACPI or similar exists to actually do
|
||||||
|
* this. If the kernel fails power-off, Finit falls back to halt.
|
||||||
*
|
*
|
||||||
* (SysV init N/A, systemd dumps its internal state to log.)
|
* (SysV init N/A, systemd dumps its internal state to log.)
|
||||||
*
|
*
|
||||||
* SIGTERM
|
* SIGTERM
|
||||||
* Like SIGUSR1, but tell kernel to reboot the system when done.
|
* Like SIGUSR2, but tell kernel to reboot the system when done.
|
||||||
*
|
*
|
||||||
* (SysV init N/A, systemd rexecutes itself.)
|
* (SysV init N/A, systemd rexecutes itself.)
|
||||||
*
|
*
|
||||||
@@ -323,7 +326,7 @@ static void sigint_cb(uev_t *w, void *arg, int events)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SIGUSR1: BusyBox style halt
|
* SIGUSR1: SysV init/systemd API socket restart
|
||||||
*/
|
*/
|
||||||
static void sigusr1_cb(uev_t *w, void *arg, int events)
|
static void sigusr1_cb(uev_t *w, void *arg, int events)
|
||||||
{
|
{
|
||||||
@@ -333,8 +336,9 @@ static void sigusr1_cb(uev_t *w, void *arg, int events)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
halt = SHUT_HALT;
|
/* Restart initctl API domain socket, similar to systemd/SysV init */
|
||||||
service_runlevel(0);
|
api_exit();
|
||||||
|
api_init(w->ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -520,7 +524,7 @@ void sig_setup(uev_ctx_t *ctx)
|
|||||||
/* Standard SysV init calls ctrl-alt-delete handler */
|
/* Standard SysV init calls ctrl-alt-delete handler */
|
||||||
uev_signal_init(ctx, &sigint_watcher, sigint_cb, NULL, SIGINT);
|
uev_signal_init(ctx, &sigint_watcher, sigint_cb, NULL, SIGINT);
|
||||||
|
|
||||||
/* BusyBox init style signals for halt, power-off and reboot. */
|
/* BusyBox/SysV init style signals for halt, power-off and reboot. */
|
||||||
uev_signal_init(ctx, &sigusr1_watcher, sigusr1_cb, NULL, SIGUSR1);
|
uev_signal_init(ctx, &sigusr1_watcher, sigusr1_cb, NULL, SIGUSR1);
|
||||||
uev_signal_init(ctx, &sigusr2_watcher, sigusr2_cb, NULL, SIGUSR2);
|
uev_signal_init(ctx, &sigusr2_watcher, sigusr2_cb, NULL, SIGUSR2);
|
||||||
uev_signal_init(ctx, &sigpwr_watcher, sigusr2_cb, NULL, SIGPWR);
|
uev_signal_init(ctx, &sigpwr_watcher, sigusr2_cb, NULL, SIGPWR);
|
||||||
|
|||||||
Reference in new issue
Block a user