dagolden / Capture-Tiny

(Perl) Capture STDOUT and STDERR from Perl, XS or external programs
http://search.cpan.org/dist/Capture-Tiny/
39 stars 19 forks source link

MSWin32 crashes on fork inside capture due to $local bug with perl <= 5.20 #30

Closed fecundf closed 8 years ago

fecundf commented 9 years ago

Due to perl bug https://rt.perl.org/Public/Bug/Display.html?id=40565 "Windows fork emulation's child pseudo process cannot restore local scalar values", Capture::Tiny crashes under MSWin32 (ActiveState, Strawberry) when the captured code forks.

I've forked this and created a test that shows the behavior, and I believe I can fix it by removing some "local" statements and emulating it. The test is at https://github.com/fecundf/Capture-Tiny/blob/master/t/25-cap-fork.t and I will write back after my patch attempt.

Related issues: rt.cpan.org #71701 "No STDERR capture from XS/C under Windows" The new test also fails to capture stderr from the child process, when run via a msys 5.8.8 perl

I think this is different from https://github.com/dagolden/Capture-Tiny/issues/12 since it is not related to "tee"

fecundf commented 9 years ago

Turns out the only "local" statments that make Win32 crash in Capture::Tiny are the local $@ statements, which are simple to fudge with lexicals. I have a patch with a rudimentary test 25-cap-fork.t which I will send as a pull request.

Alas, the new test shows that there are other problems capturing from forked code, at least on Windows, but at least it isn't a hard crash any more.

xdg commented 8 years ago

Fixed via #31