In perl.git, the branch smoke-me/davem/win32_exit has been created

<https://perl5.git.perl.org/perl.git/commitdiff/9fafc52ee15897a9f799bf28336e5f7f389a0df7?hp=0000000000000000000000000000000000000000>

        at  9fafc52ee15897a9f799bf28336e5f7f389a0df7 (commit)

- Log -----------------------------------------------------------------
commit 9fafc52ee15897a9f799bf28336e5f7f389a0df7
Author: David Mitchell <da...@iabyn.com>
Date:   Mon Apr 30 21:42:55 2018 +0100

    win323 fork(): honour PERL_EXIT_DESTRUCT_END
    
    RT #132863
    
    The PERL_EXIT_DESTRUCT_END flag in PL_exit_flags is designed to defer
    the calling of END blocks in perl_run() to being called from
    perl_destruct() instead. On UNIX-like builds, perlmain.c sets this flag.
    So main() looks like, in outline:
    
        PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
        if (!perl_parse(my_perl, xs_init, argc, argv, (char **)NULL))
            perl_run(my_perl);
        exitstatus = perl_destruct(my_perl);
    
    which means that it doesn't matter whether perl_parse() finishes
    normally or prematurely (e.g. via BEGIN { exit(1) } or BEGIN { die });
    in all cases, due to PERL_EXIT_DESTRUCT_END being set, the END blocks
    will always be called (from perl_destruct()).
    
    Commit v5.27.7-9-g8e920bd341 added PERL_EXIT_DESTRUCT_END to the
    equivalent of main() on other platforms such as win32; this
    means that the new tests in t/op/blocks.t pass on win32 too, and all
    platforms have the same behaviour for e.g.
    
        END { print "end\n"; } BEGIN { exit 1; } # prints "end"
    
    However, that commit was causing some tests in some CPAN distributions to
    hang. These were using the win32 fork() emulation.
    
    PerlProcFork() on win32 clones an interpreter, starts a new thread,
    and makes the new thread call win32_start_child(), which
    does the rough equivalent of C<perl_run(); perl_destruct();>,
    except that it rolls it's own perl_run() equivalent which
    *doesn't* honour the PERL_EXIT_DESTRUCT_END flag. So by setting
    PERL_EXIT_DESTRUCT_END, END blocks in fork()ed processes were getting
    executed twice: once by win32_start_child() emulating perl_run(),
    and once by perl_destruct() called from win32_start_child().
    
    This commit makes win32_start_child() honour PERL_EXIT_DESTRUCT_END.

-----------------------------------------------------------------------

-- 
Perl5 Master Repository

Reply via email to