From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id URdDEJ5phWP4gQEAbAwnHQ (envelope-from ) for ; Tue, 29 Nov 2022 03:08:30 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iLZwD55phWPIsgAAauVa8A (envelope-from ) for ; Tue, 29 Nov 2022 03:08:30 +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 EA5C028A71 for ; Tue, 29 Nov 2022 03:08:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozq2d-0004rF-Ti; Mon, 28 Nov 2022 21:08:11 -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 1ozq2V-0004qr-3J for bug-guix@gnu.org; Mon, 28 Nov 2022 21:08:04 -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 1ozq2U-0008IL-JN for bug-guix@gnu.org; Mon, 28 Nov 2022 21:08:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ozq2U-0001hG-8S for bug-guix@gnu.org; Mon, 28 Nov 2022 21:08:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#30948: [PATCH core-updates] guix: Reap finished child processes in build containers. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 29 Nov 2022 02:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 30948 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 30948@debbugs.gnu.org, Carlo Zancanaro Received: via spool by 30948-submit@debbugs.gnu.org id=B30948.16696876786516 (code B ref 30948); Tue, 29 Nov 2022 02:08:02 +0000 Received: (at 30948) by debbugs.gnu.org; 29 Nov 2022 02:07:58 +0000 Received: from localhost ([127.0.0.1]:52331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozq2P-0001h2-K2 for submit@debbugs.gnu.org; Mon, 28 Nov 2022 21:07:58 -0500 Received: from mail-qt1-f169.google.com ([209.85.160.169]:34703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozq2M-0001gv-FN for 30948@debbugs.gnu.org; Mon, 28 Nov 2022 21:07:55 -0500 Received: by mail-qt1-f169.google.com with SMTP id e15so8071004qts.1 for <30948@debbugs.gnu.org>; Mon, 28 Nov 2022 18:07:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=+Bd2wcIbGctVcHw9i6xtBzNE02ErQjt5rOIjPC8VuL4=; b=dA5yK2cZwAyopLqIraC4FuFVaNnJYUpsuIHvK6YoD1OuYN4VggKAx7CI3Xp3y2pIcC btjKpQux4JetUwx4u++naa3wc0BDpc/OoesmIx0B+iIkAMDq8WjHoHa7bsNWYN1XBfn+ kQ534NLBJ9OEnmMBVt6/B3bCnzskIjp4ytOfe+PmMPgZ7FIIcXIf630lWkla03Ig+1HB a/ng8EZMlKk70iwYdqANeNJSd6tDJ5wwqmCB6QHumJtD8ODUhr0TW8/8AqqAQlUuF8Rc DwSxJ2VT5ekaFGSBEaIKmhc9OzbSFukNTbuCQGJij0Iuzrw+7pg+lG8ICCHgpa81i763 dblA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+Bd2wcIbGctVcHw9i6xtBzNE02ErQjt5rOIjPC8VuL4=; b=r0jsNNlHA7lURUVZ9w7+wsMkX/CuZpxHqGwbRgfj43PyYHgVZ5hhO3dCvrI5giqWwn 59q0BzAgiGzEsNinN9LYd/ge8XnoCFIceBqIugTMXc41vLGOaZpKT0zyDCBWkPMPhwNB S3TnOJ4QSDbLeAPKGyp0os0+aOQ9rL6KMTn4rtL4PUjrFhHoh2AI/29SeHlnomAZ1eJ2 wIdsKnQ0c9zvb2u6xLIgLgmnT12f+Yowfpgri2+byvsPe4rJwjbSLI9wkKXsm1pQrVCW e8WIxOdqbnGOSv58zhwmWahNcw/xEB+s2P49zDyBfgYenFlwuAdgfqlKFsL4IesoG7JZ My2Q== X-Gm-Message-State: ANoB5pn2pHhYPm5I413neI9AYIyPxtafrrKx/PBoN9tbHMuEr2Z0J6pY 7iZxm3+ylhmXUyxRia6wa0UvSYZ0esJmPw== X-Google-Smtp-Source: AA0mqf6gj9P0lDvDpjcbCL0Kd+a74uxiwOvvV2NkwRyr1JBzUM2b97ppfTah8IdadOjqdKmIU/E4qA== X-Received: by 2002:ac8:7108:0:b0:3a5:8a24:e6bf with SMTP id z8-20020ac87108000000b003a58a24e6bfmr35864044qto.529.1669687668807; Mon, 28 Nov 2022 18:07:48 -0800 (PST) Received: from hurd ([2607:fad8:4:3::1004]) by smtp.gmail.com with ESMTPSA id d26-20020ac8545a000000b003a622111f2csm7841994qtq.86.2022.11.28.18.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 18:07:48 -0800 (PST) From: Maxim Cournoyer References: <87muyvulwt.fsf@zancanaro.id.au> <87bmf6ve6u.fsf@gnu.org> <87sh8id1mg.fsf@zancanaro.id.au> <87vadeou54.fsf@gnu.org> <87o9j5x1d4.fsf@zancanaro.id.au> <874lkxoanq.fsf@gnu.org> <87cz9cnvys.fsf_-_@gmail.com> <875yf192en.fsf@gnu.org> <87ilj1w18i.fsf@gmail.com> <87lenvce8r.fsf@gnu.org> Date: Mon, 28 Nov 2022 21:07:47 -0500 In-Reply-To: <87lenvce8r.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Mon, 28 Nov 2022 16:04:04 +0100") Message-ID: <875yeysebw.fsf@gmail.com> 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: 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=1669687710; 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=+Bd2wcIbGctVcHw9i6xtBzNE02ErQjt5rOIjPC8VuL4=; b=AST8xVHfDt1WFsY+U6/JopBtEF5QpqDbCBNRLUjg9OEo2lRX9pRaAjDGUp6nkWF/1HOOkB YYakROEnLpO8gEAa103J3VXwrYF7PVVhRIwQ3SshEkKyKBGKJdj5GK5fs0cfsb8mf5dZQR FMgtLGRCU2VzyhhhS6y09U9QtH6VIa//CRLBRornkykPfZoOky5O6fuhsGyMjfniipWX/h a13XaC2nQbc3omfMxiXIO+H1qP75neymyaSChBRhUucgVrlvwB95Irie76z1MRyZsVgKkm ZGgbVeUuzih0TUY+DEMLaAarfCDA9qDt2PSDCOuKNjy9GlMCrEg79y4Dt89dqQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1669687710; a=rsa-sha256; cv=none; b=PMOTOwnpk8YjKHonipzo4Yb6iwfQQedRtHUPsOnnoiZ/srePZnb2lpE1sTVeDw/8l83BJY /OcsKVLB7GJvl5sDArhBQxB5uHViLKhBh9SScfsSEA72CxtkRC4Do/x6aKZjvhGYtSrjlz 5l7kF9LExR4/TUc+OaV1AqjTKO+qm/ai/7B+q63oLg5u058hQHHQHemYbtUCyIv9CUvCoR 2bOx76td5fFZhwkr41+f6LpSfxOqF+G+5An2KBgg1ceSWPKIY3biLR9Cc73jbPuWDbkDCD afUaEIX2/liAcHF/qz8g/BeUKpES0TGCFscUuUK1+9/cQ9QZfKblmequaf4l0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=dA5yK2cZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: 6.04 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=dA5yK2cZ; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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: EA5C028A71 X-Spam-Score: 6.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: etU4Tmz2VhhU Hi, Ludovic Court=C3=A8s writes: > Maxim Cournoyer skribis: > >> Ludovic Court=C3=A8s writes: > > [...] > >>> If I write: >>> >>> (gexp->derivation "foo" #~(mkdir #$output)) >>> >>> I can be sure that my derivation depends on nothing but (default-guile). >>> This is important for tests, but also to make sure we can use this >>> primitive everywhere=E2=80=94if it pulled in the Shepherd, I wouldn=E2= =80=99t be able to >>> use to build glibc, because there=E2=80=99d be a cycle. >> >> I was not suggesting to pull in extra dependencies such as Shepherd, but >> to weave the to-be-added signal handling logic at a much lower level. >> One idea could be to arrange so that the correct signal handlers always >> get installed for any Guile code running in the build side (I'm not sure >> how, but perhaps by adjusting the gexp "compiler"?). >> >> The handlers could be defined in (guix build signal-handling) or >> similar. Users wouldn't need to explicitly import the module and >> install its signal handlers, that'd be taken care of automatically, all >> the time. >> >> Does that sound feasible? > > Not like this: the imported-modules derivation for (guix build > signal-handling) would be a dependency in themselves. I see a couple of options for the lowest place to inject the minimal signal handling of a PID. 1. In Guile itself. We could make it detect when it's running as PID 1 and then set up the required signal handling. This is apparently what Bash does, a peculiarity exploited by NixOS (they launch their builder scripts via Bash, which is PID 1 and takes care of reaping the dead processes) 2. In a Guile wrapper. Instead of running Guile directly in the container, guix-daemon would run it through a wrapper that acts as PID 1. This would make it a tool comparable to dumb-init [0] or tini [1], except written in Scheme. [0] https://github.com/Yelp/dumb-init/ [1] https://github.com/krallin/tini If we implement 1, it'd make Guile potentially useful as a wrapper itself to launch scripts in containerized environment (the same as tini), and it alleviates any integration overhead for us, so I find it attractive. What do you think? For further reading, see [2], which I found interesting. [2] https://medium.com/hackernoon/my-process-became-pid-1-and-now-signals-= behave-strangely-b05c52cc551c --=20 Thanks, Maxim