From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id YPDzAfp6cWNarwAAbAwnHQ (envelope-from ) for ; Mon, 14 Nov 2022 00:17:14 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id SCIcAfp6cWMHCQEAG6o9tA (envelope-from ) for ; Mon, 14 Nov 2022 00:17:14 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 31AC5163C1 for ; Mon, 14 Nov 2022 00:17:13 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouMDn-0006tk-MY; Sun, 13 Nov 2022 18:17:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouMDm-0006tG-Ie for bug-guix@gnu.org; Sun, 13 Nov 2022 18:17:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ouMDm-0005jz-AM for bug-guix@gnu.org; Sun, 13 Nov 2022 18:17:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ouMDl-0005RH-R9 for bug-guix@gnu.org; Sun, 13 Nov 2022 18:17:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#56674: [Shepherd] Use of =?UTF-8?Q?=E2=80=98waitpid=E2=80=99, _?= =?UTF-8?Q?=E2=80=98system*=E2=80=99, ?= etc. in service code can cause deadlocks Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sun, 13 Nov 2022 23:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56674 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 56674@debbugs.gnu.org Received: via spool by 56674-submit@debbugs.gnu.org id=B56674.166838140820883 (code B ref 56674); Sun, 13 Nov 2022 23:17:01 +0000 Received: (at 56674) by debbugs.gnu.org; 13 Nov 2022 23:16:48 +0000 Received: from localhost ([127.0.0.1]:48606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouMDX-0005Qk-Da for submit@debbugs.gnu.org; Sun, 13 Nov 2022 18:16:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ouMDW-0005QZ-11 for 56674@debbugs.gnu.org; Sun, 13 Nov 2022 18:16:47 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouMDQ-0005h2-Q8 for 56674@debbugs.gnu.org; Sun, 13 Nov 2022 18:16:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=I09ow4oAWCVBDXAQDdLKwhFnVAbuXwdPYh0rtdJLaJ0=; b=MMX8nd+XTEN3jU76n90U lfCCTYzy8luBzCF8s6oR/N/TYx9k/OC1L5JoBmVxzX0nARbmf4O8uVksEyU9Ag//6rNpXcZBGIjrk gBifgcaEM2Vmi7cGl3XWOTebGL1vI8pjZkTu9Tlzc2m3wT4nZor0t6mjoxWpcEXKXnz31U+LQnVIK wkobwrq+WxzI7qcPtYCIpxgKrRURq2B5Q0Kqn1O0WYWJMBCaHHNWjeQFOBhMKdRx7BctqUiA4uNxX bTJReTqia57fwqlI5Hr9ewX+1XaMO2JVSQMru8fYtM2h8Iywl+D5EME0qBtQxWTBuOpAtHaTyrsjo m+Q9d66sZinyEg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouMDQ-0001sS-E2 for 56674@debbugs.gnu.org; Sun, 13 Nov 2022 18:16:40 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <8735evpipv.fsf@inria.fr> Date: Mon, 14 Nov 2022 00:16:38 +0100 In-Reply-To: <8735evpipv.fsf@inria.fr> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Wed, 20 Jul 2022 23:39:08 +0200") Message-ID: <87o7tabg2x.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668381433; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=I09ow4oAWCVBDXAQDdLKwhFnVAbuXwdPYh0rtdJLaJ0=; b=sOYZNOIopbhQvDR8JmdFAXESdqqzUdNfr6WQbFg3lTAFXi1aHn8+XuL1hwIF4gn6AiKhli +NgOiqZR6mLTGebzqeMwXbCQ1J8Myw9Oj7Oyx2Vc+8e1GA/IZhX/QGf4VqCEsoSa/0s7K1 hFl1FtBvSDwCOa+5OdTJCBfRkW1HXMMc3MZks+XUaYcFg8sG3qirxnzTlUdhqtkFhy3jXD NL/EMyGUdA/lMSv5Ug2RjDo9QWcylIb8ACuyECTglOBN+GHB2XARcV0VDrRMFfoNi0elK6 ApiRG1Jl9nTWekTp0J4O1COiX+lKLFv4f9V5rnrMbDUT1inThfRpwd58JD41/Q== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668381433; a=rsa-sha256; cv=none; b=Wr7kKk6S1nhr5KWYF1givD7k4Y9gRA4TGC+auiWdLZYs/KqOZY1gZWwJtPfcAjCdiMDp6q CBXp+Qnag1enVt9ccvJNEC1M2vu3MSRDQnQG046T4A3coQsmxI+6W6/rG6jVOLKwo2x8FK wD6ydRpzxJja01bVsEJqpASqEihXpZjI3CaGwMqhX3ZW9OM3psJf0AcYKjsFQkhs+WIShP zrpu5vGou9gzMuxjtXAzLkD0Z7usXQFG8iBUslC/CtB7hN1ni8NFx6X9I45OqlaRxsagrX zptCNsrQEisB3REQe00QP7jYWmIHNsHpDec4E8NVvOyGfbf/IdFqSj8GkQRVew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=MMX8nd+X; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.45 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=MMX8nd+X; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 31AC5163C1 X-Spam-Score: -2.45 X-Migadu-Scanner: scn1.migadu.com X-TUID: EgeZdl2oHDTf --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Ludovic Court=C3=A8s skribis: > 1. In the best case, shepherd (as of 0.9.1) is stuck while =E2=80=98sys= tem*=E2=80=99 > is in =E2=80=98waitpid=E2=80=99 waiting for child process completion= (=E2=80=9Cstuck=E2=80=9D as > in: doesn=E2=80=99t do anything, not even answering =E2=80=98herd=E2= =80=99 requests or > inetd connections.) > > 2. I don=E2=80=99t think that can happen with =E2=80=98system*=E2=80=99= (because it=E2=80=99s in C), > but generally speaking, there=E2=80=99s a possibility that shepherd= =E2=80=99s event > loop will handle child process termination before some other > user-made =E2=80=98waitpid=E2=80=99 call does. > > Anyway, that=E2=80=99s a bad situation. > > So I can think of several ways to address it: > > 1. Change the nginx service =E2=80=98stop=E2=80=99 method to just > (make-kill-destructor), which should work just as well as invoking > =E2=80=9Cnginx -s stop=E2=80=9D. > > 2. Have Shepherd provide a replacement for =E2=80=98system*=E2=80=99. These fresh Shepherd commits install a non-blocking =E2=80=98system*=E2=80= =99 replacement: 975b0aa service: Provide a non-blocking replacement of 'system*'. 039c7a8 service: Spawn a fiber responsible for process monitoring. We=E2=80=99ll have to do more testing and probably go for a 0.9.3 release s= oon. Protip: you can test the latest shepherd with: --8<---------------cut here---------------start------------->8--- (operating-system ;; =E2=80=A6 (essential-services (modify-services (operating-system-default-essential-services this-operating-system) (shepherd-root-service-type config =3D> (shepherd-configuration (shepherd (package (inherit shepherd-0.9) (version "0.9.3pre") (source (git-checkout (url "https://git.savannah.gnu.org/git/shepherd= .git"))) (native-inputs (modify-inputs (package-native-inputs shepherd-0.9) (append autoconf automake help2man texinfo gnu-gettex= t)))))))))) --8<---------------cut here---------------end--------------->8--- Full example attached. Ludo=E2=80=99. --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline; filename=bare-bones.tmpl Content-Transfer-Encoding: quoted-printable Content-Description: the example ;; This is an operating system configuration template ;; for a "bare bones" setup, with no X11 display server. (use-modules (gnu) (guix) (guix git)) (use-service-modules networking ssh web vpn shepherd) (use-package-modules linux screen ssh admin autotools gettext man texinfo) (operating-system (host-name "komputilo") (timezone "Europe/Berlin") (locale "en_US.utf8") ;; Boot in "legacy" BIOS mode, assuming /dev/sdX is the ;; target hard disk, and "my-root" is the label of the target ;; root file system. (bootloader (bootloader-configuration (bootloader grub-bootloader) (targets '("/dev/sdX")))) ;; It's fitting to support the equally bare bones =E2=80=98-nographic=E2= =80=99 ;; QEMU option, which also nicely sidesteps forcing QWERTY. (kernel-arguments (list "console=3DttyS0,115200")) (file-systems (cons (file-system (device (file-system-label "my-root")) (mount-point "/") (type "ext4")) %base-file-systems)) ;; This is where user accounts are specified. The "root" ;; account is implicit, and is initially created with the ;; empty password. (users (cons (user-account (name "alice") (comment "Bob's sister") (group "users") ;; Adding the account to the "wheel" group ;; makes it a sudoer. Adding it to "audio" ;; and "video" allows the user to play sound ;; and access the webcam. (supplementary-groups '("wheel" "audio" "video"))) %base-user-accounts)) ;; Globally-installed packages. (packages (append (list screen strace) %base-packages)) (essential-services (modify-services (operating-system-default-essential-services this-operating-system) (shepherd-root-service-type config =3D> (shepherd-configuration (shepherd (package (inherit shepherd-0.9) (version "0.9.3pre") (source (git-checkout (url "https://git.savannah.gnu.org/git/shepherd= .git"))) (native-inputs (modify-inputs (package-native-inputs shepherd-0.9) (append autoconf automake help2man texinfo gnu-gettex= t))))))))) ;; Add services to the baseline: a DHCP client and ;; an SSH server. (services (append (list (service dhcp-client-service-type) (service nginx-service-type (nginx-configuration (server-blocks (list (nginx-server-configuration (listen '("80")) (server-name '("www.example.org= ")) (root "/srv/whatever")))))) (service wireguard-service-type (wireguard-configuration (addresses (list "10.0.0.2/24")) (dns '("10.0.0.50")))) ;does not exit (service openssh-service-type (openssh-configuration (openssh openssh-sans-x) (port-number 2222)))) %base-services))) --=-=-=--