From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from alyss.skarnet.org (alyss.skarnet.org [95.142.172.232]) by inbox.vuxu.org (Postfix) with SMTP id 2FFB92480A for ; Mon, 29 Jul 2024 19:30:23 +0200 (CEST) Received: (qmail 49046 invoked by uid 89); 29 Jul 2024 17:30:48 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 49039 invoked from network); 29 Jul 2024 17:30:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1722274187; x=1722878987; i=janbraun@gmx.de; bh=f31Y8Oe7wjiDMqAYP+9IRz1j2cUJDflG6j7qYEXPEJs=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=cNDHQGKH44xahLEFloXPQboBdoBLtI+KXqhetUcZbpYgYd38clG4/Y3UGlJXrRUL rw/ugvzaA5isHCy4PmcYvFMGovtE+9WCHyEiTlz/0KpeAInLQducefGa39RJ4wvW7 P3Hdw/1cqfuovtTTyYqusEMmQwBBbIrkXAS+s3CgfDOJ0c2LnX/N/uj5x0LTDZe+n HZYyRsGOqSH45fJyYVsLX2uvRzY9JwgtSUfU9429mPgYJo9V8Fl4cEeqb/lIOBdpi AbuyWKjERl7RzhkSVvr8R5RwW5Po61cHXVMW3bgzqp5hrgu4pOEDRAP9knqUUTv/V qQ6jR8xy3yHmvmwMTw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Date: Mon, 29 Jul 2024 19:29:45 +0200 From: Jan Braun To: Brett Neumeier Cc: Dewayne Geraghty , supervision@list.skarnet.org Subject: Re: Possible to shut down an s6 service via command rather than signal? Message-ID: Mail-Followup-To: Brett Neumeier , Dewayne Geraghty , supervision@list.skarnet.org References: <20240724123027.8c04a742f5ee892725c2120f@freesa.org> <4664aee1-4ae5-4abb-b02a-3520b259655d@heuristicsystems.com.au> <20240725112655.586841fef892611b74fa22bb@freesa.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sVJOeWedRIp57r+8" Content-Disposition: inline In-Reply-To: <20240725112655.586841fef892611b74fa22bb@freesa.org> X-GPG-Fingerprint: 1736 D50F 170B 70A6 9223 BC15 295E 703E 6D1D 2FCF X-GPG-Encryption-Welcome: always X-Provags-ID: V03:K1:fyiOwMCBQAWkQk0DYMoRxHwn2+VUS/m7LzXSB/PLyuPsGveOPyz 2jjgLl1XtHQ9WvILjz/z5aZAJHr/RQMmDrHVd3SwWU7QPumx7i6cnfu8hih1a0r1f94yPW7 f/8LYJ2pAglFKUurwulMFULYsm/NiuTDf6ZJJ/+4v/sySLhAZtbTKB8TR5ZGDGl/dlN39Xc 3MRjYSgwYD5KcoHWA7dJA== UI-OutboundReport: notjunk:1;M01:P0:in7zQMjSP5U=;Bu8ye0uUiGf8Q44tENaS87sBWsx LpX0GfM3AdpodjeiVX1P9E6VeA+2W+iu47WQGDE/l9Ija9XJBemNQMj3ZSRnEZW3JOSfkeUtD 1w9B5NbihD2xH9vd8bfp8w846abok8A6633W169X/mlY/lE50g8UKp4uehwtdPCdqyO+7QCZi NEIo11p+cjmJD7uqJqUciEsvQB3tGVl/wm/FyiiU4+0D/0aD+mU4g89hNvxZ86+NNOVgsw4fl 2Ug/jQuVyuCMWPeag0FcOzX5YgIVpFNRxFv6rNyTiyKiIcKZ8fQt/49CO+JXyo6SW4+fL74VW 5fUc1vbxh/aF+QzTU0RM1sj+gRZUw99aKD/WW+XDHWC/KJLUbEGysF5C3mO7p3ZeH4yu/kZkK ko1XPj+suc37qr2YCYrff1NSQT96gLqI95vM9FmeUAROkMUNqdBabI2rPLdh/ghyAhWMYYOE1 V73LGknxzymH8G8FfGXWoYMLGo2XrVQwqKDqV8ayO42EzieXc+xUriFxsZO6ApahNM5NH6PVh FWNl6wLlpzoKMsC71kjmliyC8gt79OWXkpYPDhEQrQKPBXxnRUu8YDAkTm5sDf6kl11uMsn8/ 6RulyDDwXNt1NWKCnOKykN/lWORI85wr6DBs0zTr7+IvdsSFukZ39kUqU0LuUWF6jPUztCnlz wxSN7kL+Ch0dEbLTRdzDtDnJKdR4Pm540J+Iy+JzcSrWCfNbFnA5LMORcLvRQdafFTgceGDIc Ir2iEK/7BseRg3am6qnw8BczVi+meOfHv0Roqvtjx2xkyRe5ESuC//jeqx+fay1ugfHC3aRo6 pUDhwb+bV+3Pg/F9GaLm92VA== --sVJOeWedRIp57r+8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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/23d89ab3bd16ebf7a864a= b75c300de7b@whitewinterwolf.com/ 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 } =20 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 =3D SHUTDOWN_CAUSE_HOST_SIGNAL; - qemu_notify_event(); +#ifdef SIGPWR + if (signal=3D=3DSIGPWR) + { + powerdown_requested =3D 1; + qemu_notify_event(); + } + else +#endif + { + shutdown_requested =3D SHUTDOWN_CAUSE_HOST_SIGNAL; + qemu_notify_event(); + } } =20 void qemu_system_shutdown_request_with_code(ShutdownCause reason, --sVJOeWedRIp57r+8 Content-Type: application/pgp-signature; name="signature.asc" -----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----- --sVJOeWedRIp57r+8--