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 sCV8EnEgAWT4DQAAbAwnHQ (envelope-from ) for ; Thu, 02 Mar 2023 23:17:21 +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 yHKzEXEgAWR+UgEAG6o9tA (envelope-from ) for ; Thu, 02 Mar 2023 23:17:21 +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 99B2F411B1 for ; Thu, 2 Mar 2023 23:17:20 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXrEX-0004vx-7C; Thu, 02 Mar 2023 17:17:05 -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 1pXrEV-0004vm-C1 for guix-patches@gnu.org; Thu, 02 Mar 2023 17:17:03 -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 1pXrEV-0006fv-2U for guix-patches@gnu.org; Thu, 02 Mar 2023 17:17:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pXrEU-0003hk-Hz for guix-patches@gnu.org; Thu, 02 Mar 2023 17:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#61803] [PATCH 0/3] [shepherd] improve race-free spawn+wait Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 02 Mar 2023 22:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61803 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ulf Herrman Cc: 61803@debbugs.gnu.org Received: via spool by 61803-submit@debbugs.gnu.org id=B61803.167779540914217 (code B ref 61803); Thu, 02 Mar 2023 22:17:02 +0000 Received: (at 61803) by debbugs.gnu.org; 2 Mar 2023 22:16:49 +0000 Received: from localhost ([127.0.0.1]:58557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXrEG-0003hE-J8 for submit@debbugs.gnu.org; Thu, 02 Mar 2023 17:16:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40480) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pXrEE-0003h1-Nn for 61803@debbugs.gnu.org; Thu, 02 Mar 2023 17: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 1pXrE5-0006W5-TS; Thu, 02 Mar 2023 17:16:37 -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=eUNM/dLNxxnB1qM90OoGm/oBFTOp8JKPiqi9YPEDLtA=; b=Djq6GpKZYx1upAMEfDCZ LeGwKl+GbZD05nH5a5s3bpYdrt+y/uUvSWEj259VuaESZ+BVr6yB419lQSlipTB7hq89s8bIL7Hp7 NSx0gwBysOlyd03DRS01gRzMJMWVoronDg/rvpPdvJfFiGQqTVd8kLWrnyl5E3SN172sbS4QAoBOr k/hyLhcJdzG6L/J4mb+plTNEADPst7lKC4ERIxZWR7b+cSc9031E0n/7bPHzTadkKXShVbr52uBSc 9YCG1Sy7PjbWrMBW0iWl8u9V8OoFrM9K4tPchLWDB8GChxFPfGOvlQz/cymNtTjI8G2zXE5ouqOP4 3v9kVo4yuJ4yMw==; 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 1pXrE3-0005xc-U8; Thu, 02 Mar 2023 17:16:37 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <87cz5x1jr2.fsf@tilde.club> Date: Thu, 02 Mar 2023 23:16:33 +0100 In-Reply-To: <87cz5x1jr2.fsf@tilde.club> (Ulf Herrman's message of "Sat, 25 Feb 2023 16:08:01 -0600") Message-ID: <87h6v23ike.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677795441; a=rsa-sha256; cv=none; b=SgnqzUXWK5grear6iyZ4cMLehoZoeBrj/zKFxqqNDWF7884v+5YkVr6o67ktOg64Yd4q9n lfPli9Nox+tZEGHsw7F4JI9Ur37DmzOAKxkxgaxCusc9iN9ohYThUvo15z/dmGQbH3kLs3 9rvUNb33nK0q6ZxGLa23TMAab5+yWvdXn8A+90fcwy/ZU9nW7Odh6GLMtgd8PGXzcw+bK3 g0yy86BmqwEol/8O0C3QwEr8/prHDXBSbNMPA+6E+Adv6s75HjkewJGBvdJfaNkvaWcZMG iT4Z4lacW2WAd5sgGqRSMw2CmlXNUCqnUmF/bknDRrWvSHabR5GXeKy232gVOQ== 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=Djq6GpKZ; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677795441; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: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=eUNM/dLNxxnB1qM90OoGm/oBFTOp8JKPiqi9YPEDLtA=; b=V7mgxezzXzod19M8e8++sr3I5Th2lfh0F8hSmqAMkVXcYP71hSQpMqSfKFMEV2b0ioYiaG KckqB3lVlo+rQc/tBGOUTZTkWW5gyqpTwGyJadA9wUJtqcNaFYO0TGjxwECMeQq6+ZW88z 4vnXeAFVG8yTO1xHH0kwm82SJiNdShu20r8Y71075+NWMVJpsMcCo9kau2zOGdW6tYBN4K cft9kEmRqPjqcOcDh7/zZ9mDswIDNFcBA4QulnNzVt7/93daZPWcGGDfJ1YSzJdYoWDaTa N66299Ja8LKFJz0lQJP9N3h8wlPwkzffIe8bUNAHTI3tYzYj0sYPObCCFv3/qA== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -4.10 X-Spam-Score: -4.10 X-Migadu-Queue-Id: 99B2F411B1 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=Djq6GpKZ; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org X-TUID: CEvxw52//LR/ Hi Ulf, Ulf Herrman skribis: > These patches fill out shepherd's procedures for running processes to > completion. They add a replacement for 'system' to complement the > existing replacement for 'system*', and add a 'fork+exec+wait-process' > procedure so that the flexibility of that family of procedures is > available for this use case as well. It also improves error handling in > the event that an exception occurs while spawning a process in the > process monitor, which would normally kill that essential fiber. Nice! > Note: I previously tried to send this to guix-devel, but it didn't seem > to make it (I didn't see it in the archives after half a day), and after > some consideration I recalled that guix-patches exists. Is this the > right place for shepherd patches? Yes, as Tobias confirmed already. :-) > From 64370a98dfc17f0531de7397a38362c03a1d89bc Mon Sep 17 00:00:00 2001 > From: ulfvonbelow > Date: Sat, 25 Feb 2023 00:42:41 -0600 > Subject: [PATCH 1/3] service: Propagate exceptions while spawning in proc= ess > monitor. > > * modules/shepherd/service.scm (unboxed-errors): new procedure. > (boxed-errors): new syntax. > (process-monitor): use it to propagate exceptions from fork+exec-comman= d via > reply channel. > (spawn-via-monitor): new procedure. > (spawn-command): use it. Good catch! I added a test and a copyright line for you (let me know if I got it wrong) and pushed as 18989f2fffa6ecdbd0f9b77834e1a54c9c45ee73. > From 51ee63ace6f3f52eb196c990664cc6b9af3d3683 Mon Sep 17 00:00:00 2001 > From: ulfvonbelow > Date: Sat, 25 Feb 2023 00:46:27 -0600 > Subject: [PATCH 2/3] service: accept fork+exec-command argument list in > monitor. > > Sometimes it's necessary to run startup / shutdown programs as a certain = user, > in a certain directory, with certain environment variables, etc. Shepherd > currently provides a replacement for system* that won't race against the > child process auto-reaper, but this lacks the flexibility Shepherd users = are > used to. > > * modules/shepherd/service.scm (process-monitor): treat command instead as > argument list to fork+exec-command. > (spawn-via-monitor): update to new convention. > (fork+exec+wait-command): new procedure. I=E2=80=99ll take a closer look to this one and report back soon. > From 177592ee9d4b7fc6dcc80e545e8ad615a1d6786c Mon Sep 17 00:00:00 2001 > From: ulfvonbelow > Date: Sat, 25 Feb 2023 00:56:57 -0600 > Subject: [PATCH 3/3] service: add spawn-shell-command replacement for > `system'. > > We already have a replacement for `system*' that avoids racing, but not f= or > `system'. > > * configure.ac (SHELL): new substitution variable. > * modules/shepherd/system.scm.in (%shell-filename): new variable. > * modules/shepherd/service.scm > (spawn-shell-command, real-system): new procedures. > * modules/shepherd.scm (main): replace `system' with `spawn-shell-command= '. Out of curiosity, do you have a need for =E2=80=98system=E2=80=99? I=E2=80= =99m inclined to recommend against its use, in which case this patch is unnecessary. > +(define %shell-filename "@SHELL@") This is the configure-time shell so it will be wrong when cross-compiling. I=E2=80=99d just do: (define %shell (or (getenv "SHELL") "/bin/sh")) Thanks! Ludo=E2=80=99.