From patchwork Sun Aug 17 18:46:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: yelninei--- via Guix-patches via X-Patchwork-Id: 43398 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 598CA27BC49; Sun, 17 Aug 2025 19:48:26 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E03E827BC4A for ; Sun, 17 Aug 2025 19:48:24 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uniQH-0006Ql-Mb; Sun, 17 Aug 2025 14:48:05 -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 1uniQF-0006Qc-B4 for guix-patches@gnu.org; Sun, 17 Aug 2025 14:48:03 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uniQF-0005uW-3I for guix-patches@gnu.org; Sun, 17 Aug 2025 14:48:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:From:Date:To:Subject; bh=GXmh8i8ezdgQxfAE8S1nPvURAxoNJRK42CWSbbPas8c=; b=V+nWMQ+WvkDF9AsJasxI/+rtf0aDyC8KGDJM67h0atKlA8yKCYqZnnwCm286H6yEtRfr7rhVwrvLdJsNv9mg4Q+yB5VdZTXUFE7CfqFEcjzeIYbqylTOVEnRo/Pdsolo5i+8O3VuBRec7JRyK1TnJUma5HA7Dxo83p7+MAKS8T+sN7LMrooAZPL3CSGe5HHIAkRXzADP4zJQRv+mpvC1G8JU0mKmwMWfi5bZQVYsiTwzNOBNgNmzVieuBHwwSvYQfUXGMktgzgGZfpt3CAlX9JoleudsWqwhDe/0+WsJepx0mgzduF4U7S4fz2NY76EkZzU2wNliiM8KtIyaATdBXg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1uniQE-0004nu-Ic for guix-patches@gnu.org; Sun, 17 Aug 2025 14:48:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77943] [PATCH 1/2] services: shepherd: Provide the right #:kernel-log-file on the Hurd. Resent-From: yelninei@tutamail.com Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 17 Aug 2025 18:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77943 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?utf-8?q?Court=C3=A8s?= Cc: 77943 <77943@debbugs.gnu.org> Received: via spool by 77943-submit@debbugs.gnu.org id=B77943.175545644518405 (code B ref 77943); Sun, 17 Aug 2025 18:48:02 +0000 Received: (at 77943) by debbugs.gnu.org; 17 Aug 2025 18:47:25 +0000 Received: from localhost ([127.0.0.1]:47925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uniPc-0004mm-HY for submit@debbugs.gnu.org; Sun, 17 Aug 2025 14:47:24 -0400 Received: from mail.w13.tutanota.de ([185.205.69.213]:55910) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uniPZ-0004mT-1i for 77943@debbugs.gnu.org; Sun, 17 Aug 2025 14:47:22 -0400 Received: from tutadb.w10.tutanota.de (w10.api.tuta.com [IPv6:fd:ac::d:10]) by mail.w13.tutanota.de (Postfix) with ESMTP id 12B70B3B28C7 for <77943@debbugs.gnu.org>; Sun, 17 Aug 2025 20:46:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1755456404; s=s1; d=tutamail.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=GXmh8i8ezdgQxfAE8S1nPvURAxoNJRK42CWSbbPas8c=; b=s+VV8B7MDzYvXYirmMIc9g4tcrylNqFIy/GJwKF+iwdihXxXnjtwJY0y+bkwC9Kg XZGcMRT5fAEHPUQbQnPJZweYjgVCA2h4UV3aA9qKskBdtIqN9cKJQsA6YhRMXi6t/Cx LLpjxDLBQhFF7oBUFwA3Lp1BHa3y6AHsWObKb+vEeHaG26zJRZ2l3wW05xJ/I9F+SuM /qnBK+gDmkj1cewv7XlaNX8A9azGonfmCcysb0FTBbh8hzjaRV2eOWWkIcl+gAOfKoT tJU2y4vVnyqLVICsdm72KQ/N/A2HIKB8CaWqoRTRBy746++mcY0mGC6Ntnf7wDeVIpW /DF0Z5NGFQ== Date: Sun, 17 Aug 2025 20:46:44 +0200 (CEST) Message-ID: In-Reply-To: <87sehqq8ys.fsf@gnu.org> References: <87cybmp4q6.fsf@gnu.org> <87frg7kbm3.fsf@gnu.org> <87sehqq8ys.fsf@gnu.org> MIME-Version: 1.0 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: , Reply-to: yelninei@tutamail.com X-ACL-Warn: , yelninei--- via Guix-patches X-Patchwork-Original-From: yelninei--- via Guix-patches via From: yelninei--- via Guix-patches via Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi. Aug 17, 2025, 15:19 by ludo@gnu.org: > > > So you have a patch for /hurd/streamio and a C reproducer? (Maybe you > sent it already and I haven’t seen.) > No i have not sent this: Something like this fixes the D_WOULD_BLOCK errno. --8<---------------cut here---------------start------------->8--- --8<---------------cut here---------------end--------------->8--- Some c code that runs fgets in a loop until an error --8<---------------cut here---------------start------------->8--- #include #include #include #include #include #include #define _PATH_KLOG "/dev/klog" int main () {   ssize_t n;   int fd;     fd = open(_PATH_KLOG, O_RDONLY | O_NONBLOCK | O_CLOEXEC);   if (fd < 0)     {       perror("open");       exit(EXIT_FAILURE);     }   FILE* file = fdopen(fd, "r");      char* line;   int line_max = 1024;   line = malloc(line_max +1);   if(line == NULL)     {       perror("malloc");       exit(EXIT_FAILURE);     }   // The first read always fails with EWOUDLBLOCK   fgets(line, line_max +1 , file);   perror("fgets");   errno = 0;   while(fgets(line, line_max +1 , file) != NULL)     {       printf("%s", line);     }   perror("fgets");      free(line);   close(fd);   exit(EXIT_SUCCESS); } --8<---------------cut here---------------end--------------->8--- I am using `(cross-gcc-toolchain "i586-pc-gnu")` to get a cross compiler with a bit of a hack to remove the %hurd-system supported-system restriction from the hurd and mach headers. >> However this does not really help the shepherd syslog because guile's >> read-line blocks forever waiting for a terminating newline. Also guile >> is unaware that further attempts to read would EWOULDBLOCK as "(select >> (vector port) #() #() 0)" indicates that reading is possible but then >> actually trying to a get a char blocks. >> > > Ah but I think that’s fine: shepherd, suspendable ports are enabled (via > Fibers), which means that read attempts that return EAGAIN or > EWOULDBLOCK result in the calling fiber being suspended. > > You would need to try this for real, but it should be fine. > It is fine in the sense that fibers suspends the system-log successfully at the "end" of /dev/klog. However It is not fine because it will never wake up it up again. According to the c example it now returns EWOULDBLOCK as expected.From testing around a bit I think it might be (@ (ice-9 rdelim) read-line) waiting for a terminating newline. And again when I retried this just now there was the noticable delay with anything shepherd when the shepherd-syslog is running (default (system-log-configuration) configuration) > Thanks! > > Ludo’. > diff --git a/trans/streamio.c b/trans/streamio.c index e42ff908..93057146 100644 --- a/trans/streamio.c +++ b/trans/streamio.c @@ -1049,6 +1049,8 @@ device_read_reply_inband (mach_port_t reply, kern_return_t errorcode,      input_pending = 0;    err = errorcode; +  if (err == D_WOULD_BLOCK) +    err = EWOULDBLOCK;    if (!err)      {        if (datalen == 0)