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=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 1714 invoked from network); 24 Feb 2022 05:16:20 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 24 Feb 2022 05:16:20 -0000 Received: (qmail 30043 invoked by uid 89); 24 Feb 2022 05:16:44 -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 30036 invoked from network); 24 Feb 2022 05:16:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thescrapyard-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=73dW4src6dN8ZKQGnLa+qh8PG8Az7/lhyHQleeL6I/0=; b=o40JsShdNlsnsyKGyMsCMTD/lEAhx4PYcpU7Kxu5ugzqSps6R6uPxX9TzcGlTreoWK yKXRGqpMP/olv4F0r2LDd4gexTGFv8Y8rpDcaZ42BhZZAoui5hQT2zbS6rOHp9dJozo8 mrzMp4nBcqC/U7XCpsgJ8zoQtxBMFmHMuXZ1kHVOd7791aKIScKQGli/OkFQqfA6HIUk 09yl2PwvfeYdpmRUK4REXW5GelxvnE8PpfHJkQUaadQjHLRL+w8CeHhCVoh+gVxMUJot TcFGFpFmZ3PQ+KwPazP5z6bEGgV9xLfGmpnvToSp72MuoVE7904tSu3qyYzk/DZVhw4p gsqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=73dW4src6dN8ZKQGnLa+qh8PG8Az7/lhyHQleeL6I/0=; b=EmMjrcRPyN/n4qB7OWSu+95BJNnkPH1JWIFUt+ROUQ6ghB31VjyQMyEYFYnd0ENpIs gpiY0hbUK58+Tjids8hNSuzfdDRhKSsQjY4nMZpuyKzjg++MLvtDG8ELXz/9Zo4aOefH QEP1kXCK6IvWybwskwpWx9xtOuqeFH6EeIOIBRplsUaJS/Qh2gzUpdLsIL51p+1evKg1 NU8NXcpvlgYZzRwhkodC1PkU2O5O7tSfzbS538U06kaKvmE+Y4NDg4QN9SGx3F3iKleX 4XHVFHfp8cn+zskDRa+s2HSS/j5TSFjwVl7qGN0OxdYkaRkJj2BaaGZrYjOGXAeZsiad rlTQ== X-Gm-Message-State: AOAM531qs8oFU0T5uIJUC3+v2Ra7qT+qSGY+pcySWbK7QGAdDsbzNegJ cFLJf6YMOeHymEGOIyU7NvpkoPB+6Hk8+QcHRk8OIAXBQ+Q= X-Google-Smtp-Source: ABdhPJygP9YnS7/dgW+b3sWxlipSsShMjJd+WZNGLor+hc7mbtFsJfjH5YCso9jM6yTO4V9paoXXytl/ubzN1bLmStU= X-Received: by 2002:a17:90b:3503:b0:1bc:5d68:e7a2 with SMTP id ls3-20020a17090b350300b001bc5d68e7a2mr1110777pjb.29.1645679775793; Wed, 23 Feb 2022 21:16:15 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jan-willem De Bleser Date: Wed, 23 Feb 2022 21:16:04 -0800 Message-ID: Subject: Re: s6-svscan shutdown notification To: supervision@list.skarnet.org Content-Type: multipart/alternative; boundary="000000000000735d1605d8bcae77" --000000000000735d1605d8bcae77 Content-Type: text/plain; charset="UTF-8" Not an option to be its parent since there's no persistent supervisor of a jail's root process, but that script using .s6-svscan/finish should do nicely. Thanks for the suggestion! - Jw On Wed, Feb 23, 2022 at 9:04 PM Laurent Bercot wrote: > > >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 > > --000000000000735d1605d8bcae77--