]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/TestCommon.pm
clone|--mirror: fix and test against pre-manifest WWW
[public-inbox.git] / lib / PublicInbox / TestCommon.pm
index 9e15239465aabe05728603b3db8869f48f128b7c..cd706e0eae2dafeedcc310d52e0e52b4b4d8e0dc 100644 (file)
@@ -316,8 +316,10 @@ sub run_script ($;$$) {
        } else { # localize and run everything in the same process:
                # note: "local *STDIN = *STDIN;" and so forth did not work in
                # old versions of perl
+               my $umask = umask;
                local %ENV = $env ? (%ENV, %$env) : %ENV;
-               local %SIG = %SIG;
+               local @SIG{keys %SIG} = map { undef } values %SIG;
+               local $SIG{FPE} = 'IGNORE'; # Perl default
                local $0 = join(' ', @$cmd);
                my $orig_io = _prepare_redirects($fhref);
                my $cwdfh = $lei_cwdfh;
@@ -332,6 +334,7 @@ sub run_script ($;$$) {
                die "fchdir(restore): $!" if $cwdfh && !chdir($cwdfh);
                _undo_redirects($orig_io);
                select STDOUT;
+               umask($umask);
        }
 
        # slurp the redirects back into user-supplied strings
@@ -466,6 +469,7 @@ sub start_script {
                        $ENV{LISTEN_PID} = $$;
                        $ENV{LISTEN_FDS} = $fds;
                }
+               if ($opt->{-C}) { chdir($opt->{-C}) or die "chdir: $!" }
                $0 = join(' ', @$cmd);
                if ($sub) {
                        eval { PublicInbox::DS->Reset };