From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id CGxaE3OagWbsYAAAe85BDQ:P1 (envelope-from ) for ; Sun, 30 Jun 2024 17:48:35 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id CGxaE3OagWbsYAAAe85BDQ (envelope-from ) for ; Sun, 30 Jun 2024 19:48:35 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BObXmImC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1719769715; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=WykEUBB2qQamrPp+sd7zhuzfKO+r5y6Nx6tesRhgcEc=; b=gLWgupAcMj+xDnKZ2eUnTnQZbauN06dwcX1TT3AU7M0cQIzQJorpr3/ddrP5jkMpGxujhk kJvquAikiOC4np8soZYWUfXC5pBlE2OmF6YHNgYUnOzQLJZsICce3Fj8U5Jbz+jDnvnuzM QfWJUmS/6qaZ6q8X6/1/CALClxFxXE4gEpzDer1O5N9uauhLWq6YjWKu6zuc1GL/KyDvJd 0lsvF+rCMhURpvSF63BaItuue5fzQcH1QUtgUL/qSZzUbqzqip1F09MlaicyZhMdxSbWA7 hiKMfRmBsM3YMxMhigq2yNdm7FyEdT1TGBEgJmGgxNVuEk2KK/7MP1PXT/v63g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1719769715; a=rsa-sha256; cv=none; b=nvYuep1CD0cZgF9vsGfMpuXE70fbsmiLRtXmYbr/Ca9vhPL3sG1grOU/x3prlrKvNOqwRR JLTs5LApY8459pdG2Xd47Qwn0B8bqMKFyJ3f1+c0GRyLK4V4idkmUpTn/qeDH8B5VoO8VI EBW0hBDrkZdDD2obwD8Vpgvw3t5ZTz5IM13icrmqLDfn8RbwZOfciSmCU4OUYecVg2auVE bwcH/5GSiEc8Nm3GkNJqiqjQLXtKbzdxtAYDput/6OzaAHTjV7F5l2hLcm0notW7rdBk32 iFHg8R9ma6mjmXJMsEhQd7/sLOsuCfFDs4f19OnMP/d+NDcIZUFJG0ls0IVtSg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BObXmImC; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" 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 247B119935 for ; Sun, 30 Jun 2024 19:48:35 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNyeQ-0001b8-83; Sun, 30 Jun 2024 13:47:49 -0400 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 1sNxDP-0005Gt-Ml for guix-devel@gnu.org; Sun, 30 Jun 2024 12:15:47 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNxDO-0005AT-4C for guix-devel@gnu.org; Sun, 30 Jun 2024 12:15:47 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a689ad8d1f6so256659566b.2 for ; Sun, 30 Jun 2024 09:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719764144; x=1720368944; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WykEUBB2qQamrPp+sd7zhuzfKO+r5y6Nx6tesRhgcEc=; b=BObXmImC7gd5TypGMe5iDaRoXpr5Ai3QODc3SsqvH4O1bSQASr8lJYpQwAxPADS5TZ 5Kput79EF3n49pMsvgVhA5KpEn1BWTSIILnJ9Zjp3lrFU8jxroRYYez7cpAFWHeXF8cy Kh7ACbbrPpnpbJkumHqUohjDSFSZvGUFPi2y+RkzzBFeFic3nLHhiTFfHJPv8OJ1xuFp cK+3GaWuw2noBa9SXfd9h4icaO5qi8PvB6HV7QHlzhOm/4H1RLhGfv+XyEOM8ZMUIPTx YrhRfTkbc7Ap2UPuVd/ji5D6pu4sDbU58qhZjOT23z65q7N3n/ZPfM6sBMYxev41MRjT VGdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719764144; x=1720368944; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WykEUBB2qQamrPp+sd7zhuzfKO+r5y6Nx6tesRhgcEc=; b=G43mgVk6rbt0lwqOEHC0kxTIWI5FcijI844p7dGTanwIB7WJZ6mEpvi70nxyTwxmM6 C2W+gsjPSv7VGkU2qMgx8srs1o3s5WGO0J9hVzwfV8Y+J/kyaPdz0WBaZxyIxzc4t5Ud fhCKWjez4dNW5Mz0URJKB4z2qtVBGMCwhwxedWHwswr7yyPgZcqH22qJNBtNPoU2wteE iiOkaUByOI78jrovCap8ElGYwGhf2uCcgUQK9mdFqJAu+ED87QhRnCGtgEZnNcqBDQGy i+fwJmKJy4lqp2JqDDsKrMUHoXR54c9Ymz4tWL76P/tPW1/R5jZiKncLfi462jpBOU9C 8QRQ== X-Gm-Message-State: AOJu0YwgE7ZmKXgo+YCetom86YFh6Rwe1+EP3J2TRafFyilmCVeoE/cn 4PhQF37SKKx1XNukmQ6s6POZAFeoXBI5mYHuhg4IUOy8WHxTuln0b7/jvQ== X-Google-Smtp-Source: AGHT+IHTMk52GwFMr7QMz4znPIhUJF6ryc7+Ok38qKzBofpjdcDtQ2I+yMejbTcAExPpmOkdbHNtpA== X-Received: by 2002:a17:907:da0:b0:a72:631d:6de1 with SMTP id a640c23a62f3a-a75143e7022mr303144566b.20.1719764143492; Sun, 30 Jun 2024 09:15:43 -0700 (PDT) Received: from lelap.lan (2a00-1f40-b161-2920--477.pool6.panelnet.hu. [2a00:1f40:b161:2920::477]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf1bc08sm252509666b.28.2024.06.30.09.15.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jun 2024 09:15:43 -0700 (PDT) From: attila.lendvai@gmail.com X-Google-Original-From: attila@lendvai.name To: guix-devel@gnu.org Cc: Attila Lendvai Subject: [PATCH shepherd] service: Factor out SEND-TO-PROCESS-MONITOR. Date: Sun, 30 Jun 2024 18:13:03 +0200 Message-ID: <20240630161303.22507-6-attila@lendvai.name> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240630161303.22507-2-attila@lendvai.name> References: <20240630161303.22507-2-attila@lendvai.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=attila.lendvai@gmail.com; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 30 Jun 2024 13:47:43 -0400 X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 247B119935 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -9.22 X-Spam-Score: -9.22 X-TUID: P4mzgVNFp+DY From: Attila Lendvai Assert that (CURRENT-PROCESS-MONITOR) is valid. * modules/shepherd/service.scm (send-to-process-monitor): New function. (handle-SIGCHLD), (process-monitor), (monitor-service-process), (terminate-process): Use it. --- modules/shepherd/service.scm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm index d9dc0d5..e1c602c 100644 --- a/modules/shepherd/service.scm +++ b/modules/shepherd/service.scm @@ -2351,8 +2351,7 @@ otherwise by updating its state." #t) ((pid . status) ;; Let the process monitor handle it. - (put-message (current-process-monitor) - `(handle-process-termination ,pid ,status)) + (send-to-process-monitor `(handle-process-termination ,pid ,status)) ;; As noted in libc's manual (info "(libc) Process Completion"), ;; loop so we don't miss any terminated child process. @@ -2488,10 +2487,13 @@ which its completion status will be sent." (values (unboxed-errors (get-message reply)) reply))) +(define (send-to-process-monitor message) + (assert (current-process-monitor)) + (put-message (current-process-monitor) message)) + (define (spawn-via-monitor arguments) (let ((reply (make-channel))) - (put-message (current-process-monitor) - `(spawn ,arguments ,(current-service) ,reply)) + (send-to-process-monitor `(spawn ,arguments ,(current-service) ,reply)) (unboxed-errors (get-message reply)) (get-message reply))) @@ -2539,8 +2541,7 @@ while waiting for @var{program} to terminate." "Monitor process @var{pid} and notify @var{service} when it terminates." (assert (current-process-monitor)) (let ((reply (make-channel))) - (put-message (current-process-monitor) - `(await ,pid ,reply)) + (send-to-process-monitor `(await ,pid ,reply)) (spawn-fiber (lambda () (let ((status (get-message reply))) @@ -2583,7 +2584,7 @@ group; wait for @var{pid} to terminate and return its exit status. If @var{pid} is still running @var{grace-period} seconds after @var{signal} has been sent, send it @code{SIGKILL}." (let ((reply (make-channel))) - (put-message (current-process-monitor) `(await ,(abs pid) ,reply)) + (send-to-process-monitor `(await ,(abs pid) ,reply)) (catch-system-error (kill pid signal)) (match (get-message* reply grace-period #f) @@ -2904,4 +2905,3 @@ we want to receive these signals." "This does not work for the 'root' service." (lambda (running) (local-output (l10n "You must be kidding."))))))) - -- 2.45.2