From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 05C741F670; Sun, 27 Feb 2022 11:17:15 +0000 (UTC) Date: Sun, 27 Feb 2022 11:17:14 +0000 From: Eric Wong To: Julien Moutinho Cc: Dominique Martinet , meta@public-inbox.org Subject: [PATCH] t/lei-sigpipe: ensure SIGPIPE is unblocked for this test Message-ID: <20220227111714.GA13350@dcvr> References: <20211208040836.GA27368@dcvr> <20211209013743.okzgim7bbrpahks7@sourcephile.fr> <20220217210233.GA31923@dcvr> <20220220013853.4vtvnyvpaichgpkm@sourcephile.fr> <20220222064424.GA11876@dcvr> <20220227041533.5dvcuuaffjhzrhuw@sourcephile.fr> <20220227064144.wo3flsc2xboks6sg@sourcephile.fr> <20220227080422.gyqowrxomzu6gyin@sourcephile.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220227080422.gyqowrxomzu6gyin@sourcephile.fr> List-Id: Julien Moutinho wrote: > Le dim. 27 févr. 2022 16h23 +0900, Dominique Martinet a écrit : > > I guess we can now open a nix issue asking to reset signal handlers > > after fork, before executing its builder?... > Well spotted Dominique, thanks! > > Turns out this is actually systemd which ignores SIGPIPE. > I'm able to pass t/lei-sigpipe.t when my `nix build` > connects to a nix-daemon run manually outside systemd. > There is already a 3yo issue on nix's tracker for that: > https://github.com/NixOS/nix/issues/2803 > suggesting to add to nix-daemon.service: > > [Service] > > IgnoreSIGPIPE=no > And that indeed also makes t/lei-sigpipe.t succeed. > > In the meantime I'll disable t/lei-sigpipe.t > to finally get public-inbox added to Nixpkgs. > > Thank you Dominique and Eric! You're welcome and thank you for tracking this down. Yes, blocking SIGPIPE makes sense for most daemons so I think systemd is being reasonable, here. However, this lei test is for simulating an interactive environment, so re-enabling SIGPIPE under t/lei-sigpipe.t seems best... I initially considered adding this for all test_lei(), but most lei tests don't care and I didn't want to waste CPU time. ------8<----- Subject: [PATCH] t/lei-sigpipe: ensure SIGPIPE is unblocked for this test Tests run under systemd (and similar) have SIGPIPE blocked by default. This was causing this SIGPIPE test to get stuck when run by automated builders used by Nix. Thanks to Julien Moutinho and Dominique Martinet for tracking down this failure. Reported-by: Julien Moutinho Reported-by: Dominique Martinet Link: https://public-inbox.org/meta/20220227080422.gyqowrxomzu6gyin@sourcephile.fr/ --- t/lei-sigpipe.t | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/t/lei-sigpipe.t b/t/lei-sigpipe.t index 6b2772a6..7fab9aeb 100644 --- a/t/lei-sigpipe.t +++ b/t/lei-sigpipe.t @@ -1,10 +1,25 @@ #!perl -w -# Copyright (C) 2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ use strict; use v5.10.1; use PublicInbox::TestCommon; -use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE); +use POSIX qw(WTERMSIG WIFSIGNALED SIGPIPE SIG_UNBLOCK SIG_SETMASK sigprocmask); +use PublicInbox::OnDestroy; + +# undo systemd (and similar) blocking SIGPIPE, since lei expects to be run +# from an interactive terminal: +# https://public-inbox.org/meta/20220227080422.gyqowrxomzu6gyin@sourcephile.fr/ +my $set = POSIX::SigSet->new; +my $old = POSIX::SigSet->new; +$set->emptyset or xbail "sigemptyset $!"; +$old->emptyset or xbail "sigemptyset $!"; +$set->addset(SIGPIPE); +sigprocmask(SIG_UNBLOCK, $set, $old) or xbail "SIG_UNBLOCK: $!"; +my $cleanup = PublicInbox::OnDestroy->new($$, sub { + sigprocmask(SIG_SETMASK, $old); +}); + test_lei(sub { my $f = "$ENV{HOME}/big.eml"; my $imported;