From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 1DE271F53A for ; Tue, 21 Mar 2023 23:07:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1679440068; bh=KILAC3gh6tI1yFdO1bVS8R4fmVTZKCmPUKMzFn+/OmU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UgxswdNYItChKlgCucvsVq5OxLCFPUw+YDTKef0Fo0p81QrVj44l6qGLFtP6pML6+ F1q43yXDfBvwCVHkkeQZmVE9QJtYlv3RwKBAA57LQ1T78pOGVwt7xf741WcurmNThi 0Tp8+o2rFYAwx/b+dqtZhGab4tbWmwRatnvJQfGw= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 22/28] spawn: show failing directory for chdir failures Date: Tue, 21 Mar 2023 23:07:37 +0000 Message-Id: <20230321230743.3020032-22-e@80x24.org> In-Reply-To: <20230321230743.3020032-1-e@80x24.org> References: <20230321230701.3019936-1-e@80x24.org> <20230321230743.3020032-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Our use of `git rev-parse --git-dir' depends on our (v)fork+exec wrapper doing chdir, so the error message is required to avoid user confusion. I'm still avoiding `git -C $DIR' for now since ancient versions of git did not support it. --- lib/PublicInbox/Spawn.pm | 6 ++++-- lib/PublicInbox/SpawnPP.pm | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index dc11543a..878843a6 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -122,8 +122,10 @@ int pi_fork_exec(SV *redirref, SV *file, SV *cmdref, SV *envref, SV *rlimref, exit_err("setpgid", &cerrnum); for (sig = 1; sig < NSIG; sig++) signal(sig, SIG_DFL); /* ignore errors on signals */ - if (*cd && chdir(cd) < 0) - exit_err("chdir", &cerrnum); + if (*cd && chdir(cd) < 0) { + write(2, "cd ", 3); + exit_err(cd, &cerrnum); + } max_rlim = av_len(rlim); for (i = 0; i < max_rlim; i += 3) { diff --git a/lib/PublicInbox/SpawnPP.pm b/lib/PublicInbox/SpawnPP.pm index 5609f74a..d6c863f8 100644 --- a/lib/PublicInbox/SpawnPP.pm +++ b/lib/PublicInbox/SpawnPP.pm @@ -37,7 +37,7 @@ sub pi_fork_exec ($$$$$$$) { } $SIG{$_} = 'DEFAULT' for grep(!/\A__/, keys %SIG); if ($cd ne '') { - chdir $cd or die "chdir $cd: $!"; + chdir $cd or die "cd $cd: $!"; } while (@$rlim) { my ($r, $soft, $hard) = splice(@$rlim, 0, 3);