From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id A1A321FF138 for ; Wed, 04 Mar 2026 14:46:27 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7180BA4C2; Wed, 4 Mar 2026 14:47:26 +0100 (CET) From: Hannes Laimer To: pve-devel@lists.proxmox.com Subject: [PATCH pve-common 1/1] RESTEnvironment: periodically reap workers as SIGCHLD fallback Date: Wed, 4 Mar 2026 14:46:48 +0100 Message-ID: <20260304134649.82272-2-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260304134649.82272-1-h.laimer@proxmox.com> References: <20260304134649.82272-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1772631986645 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.065 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 22NHIVOWBSCZEVAWBHYTEAGQJDDVUVL4 X-Message-ID-Hash: 22NHIVOWBSCZEVAWBHYTEAGQJDDVUVL4 X-MailFrom: h.laimer@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Libraries may temporarily override $SIG{CHLD}, causing worker exit signals to be lost. Poll worker_reaper every 5 seconds via an AnyEvent timer to catch any missed signals in API server contexts where this can be problematic. Signed-off-by: Hannes Laimer --- src/PVE/RESTEnvironment.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm index 81d7e29..cb44823 100644 --- a/src/PVE/RESTEnvironment.pm +++ b/src/PVE/RESTEnvironment.pm @@ -37,6 +37,7 @@ my $rest_env; my $WORKER_PIDS; my $WORKER_FLAG = 0; +my $worker_reaper_timer; my $log_task_result = sub { my ($upid, $user, $status) = @_; @@ -124,6 +125,14 @@ sub init { } }; + # Periodically reap workers as a fallback in case a library call temporarily overrides + # $SIG{CHLD} and causes us to miss a signal. Only useful when an event loop is running. + $worker_reaper_timer = AnyEvent->timer( + after => 5, + interval => 5, + cb => sub { $worker_reaper->() }, + ); + # environment types # cli ... command started fron command line # pub ... access from public server (pveproxy) -- 2.47.3