From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 32344 invoked from network); 24 Feb 2022 05:04:08 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 24 Feb 2022 05:04:08 -0000 Received: (qmail 29528 invoked by uid 89); 24 Feb 2022 05:04:30 -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 29521 invoked from network); 24 Feb 2022 05:04:29 -0000 From: "Laurent Bercot" To: supervision@list.skarnet.org Subject: Re: s6-svscan shutdown notification Date: Thu, 24 Feb 2022 05:04:02 +0000 Message-Id: In-Reply-To: References: Reply-To: "Laurent Bercot" User-Agent: eM_Client/8.2.1659.0 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable >What's the cleanest way to wait on s6-svscan to shut down after issuing of >a SIGTERM (say s6 via-svscanctl -t)? Be its parent, and wait for it. :) On SIGTERM, s6-svscan will not exit until the supervision tree is entirely down, so that will work. If you're not the parent, then you'll have to wait for a notification somehow, but that's easy: When s6-svscan wants to exit, it doesn't exit right away, but tries to exec into the .s6-svscan/finish script. So you have a clear indicator here: when .s6-svscan/finish runs, it means the supervision tree is down. So, for instance, make a finish script that writes a byte in a fifo, and have your jail shutdown script read on that fifo. Something like: .s6-svscan/finish: #!/bin/sh exec echo > /run/blah/fifo shutdown script: #!/bin/sh ... rm -f /run/blah/fifo mkfifo /run/blah/fifo read < /run/blah/fifo & s6-svscanctl -t /run/service wait ... (read on the fifo before running s6-svscanctl, to avoid the small race condition.) >Looking at the documentation, my only option appears to be to check if the >return code of s6-svscanctl is 100, or maybe to monitor for the existence >of .s6-svscan/control (not sure if it's removed on exit). Are there any >other ways to monitor s6-svscan? Ew. Don't poll. Use .s6-svscan/finish to do anything you want to do at s6-svscan death time. -- Laurent