Re: Possible to shut down an s6 service via command rather than signal?
Jan Braun <[email protected]> Mon, 29 Jul 2024 19:29:45 +0200
| Newsgroups | gmane.comp.sysutils.supervision.general |
|---|---|
| Message-ID | <ZqfRifjzvhkm5JCc@abakus> |
Brett Neumeier schrob: > 2. patch QEMU to add a signal handler so that it will gracefully > shutdown when it receives a specific signal (and then tell s6 to use > that signal to take the service down); or A patch to do that has been available since 2017 at least, but the qemu developers apparently can't agree to any signal to use. See https://patchwork.kernel.org/project/qemu-devel/patch/[email protected]/ and https://gitlab.com/qemu-project/qemu/-/issues/148 . Here's a current version with SIGPWR. HTH, Jan diff --git a/os-posix.c b/os-posix.c index 43f9a43f3..55fb3999a 100644 --- a/os-posix.c +++ b/os-posix.c @@ -64,6 +64,9 @@ void os_setup_signal_handling(void) sigaction(SIGINT, &act, NULL); sigaction(SIGHUP, &act, NULL); sigaction(SIGTERM, &act, NULL); +#ifdef SIGPWR + sigaction(SIGPWR, &act, NULL); +#endif } void os_set_proc_name(const char *s) diff --git a/system/runstate.c b/system/runstate.c index c833316f6..a75c10aa6 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -680,8 +680,18 @@ void qemu_system_killed(int signal, pid_t pid) /* Cannot call qemu_system_shutdown_request directly because * we are in a signal handler. */ - shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL; - qemu_notify_event(); +#ifdef SIGPWR + if (signal==SIGPWR) + { + powerdown_requested = 1; + qemu_notify_event(); + } + else +#endif + { + shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL; + qemu_notify_event(); + } } void qemu_system_shutdown_request_with_code(ShutdownCause reason,
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEFzbVDxcLcKaSI7wVKV5wPm0dL88FAman0YQACgkQKV5wPm0d L8/gtRAAj+DRtoQv0bAcYEHjlOiB2uGObnU7cEai4s3rBPQAbxV1bU+ZDa9QYMPO yIzAXpm/XeLrEiohl614I3thxv7QEUhdoznWXI0wtiFxRm7BryMpyIYyIPVDR5CD kAvkOID84hyIG725vLtyykkMiVGOJrISEWnBBQ57rkPfBtf7i8Zd3HlOEKhg56Rv 6J5UIJyW4As015m8pu85swbtEDtpuKCiODrqg6iB0kWK7PcrHgWmsDFoLiwH3Zm7 Dff7bnW6osElOzHbys37Ny6r6Oo61gKYnTa8/0GUQ/knvmkkciChHUO9b1nuUQIG EjxdGq6oMGxLnc033SjT+4z5BsPiHTA9idQRWJgTTLtHn9A+uU+GEHAoBCRaqdAg bp3vxAe65m8hIVt3DKzFojftlU07etxvWlMu3TFnbSEBwVGXeE2BjuinSIZqgLAu LbkEsotY00KpU/ZCqDCd3K5R4/ZGbatpT5aR+RmiLgV96f80xsbdkzkSff4k3U7Q 2o8xcFCXso3z0v4GljuajyWHNVWld1XCym3G8+1tIvdQQCSJ1qnOg53Ib3p3KS3z BtzqHJ1K6X2/GkCypctlrkTq3ZBclLlNQJxojI8o6kg5BT80oMgx8RRmTzqmaHzO 3GwkSEy0nKRkcMjoFV1EVikP2s+aeDyp3w46RxhM1VPIdvayG6U= =Wrnp -----END PGP SIGNATURE-----