This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Cleanup all scopes before exiting a pseudo-forked process.
[perl5.git] / win32 / perlhost.h
index 61f8765..5e89f85 100644 (file)
@@ -1769,6 +1769,11 @@ restart:
        switch (status) {
        case 0:
            CALLRUNOPS(aTHX);
+            /* We may have additional unclosed scopes if fork() was called
+             * from within a BEGIN block.  See perlfork.pod for more details.
+             */
+           while (PL_scopestack_ix > oldscope)
+               LEAVE;
            status = 0;
            break;
        case 2: