]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
spawn: show failing directory for chdir failures
authorEric Wong <e@80x24.org>
Tue, 21 Mar 2023 23:07:37 +0000 (23:07 +0000)
committerEric Wong <e@80x24.org>
Sat, 25 Mar 2023 09:37:57 +0000 (09:37 +0000)
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
lib/PublicInbox/SpawnPP.pm

index dc11543a98abd27e523eb119df3e640aa889133a..878843a60a8dd1c58383e6437ad3549c453ce7dd 100644 (file)
@@ -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) {
index 5609f74a8781a49530fed377e031112ab4cdeead..d6c863f81e201ef63f3345363b1e6810a131cb06 100644 (file)
@@ -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);