I think I nailed down the problem's cause. A simpler test case is
perl -e 'use Cwd; print getcwd'
At some point this issues the following Cygwin calls
  168 4607616 main perl 9268 mount_info::conv_to_win32_path: src_path //Cwd.dll, dst \\Cwd.dll, flags 0x2, rc 0
  170 4607786 main perl 9268 build_fh_pc: fh 0x61276450, dev 000000C2
  937 4608723 WNetOpenEnum perl 9268 cygthread::stub: thread 'WNetOpenEnum', id 0x1A58, stack_ptr 0x109AD40
--- Process 9268, exception 000006ba at 767DC41F
2273000 6881723 main perl 9268 __set_errno: int stat_worker(path_conv&, stat*):1880 setting errno 2
Note that //Cwd.dll is interpreted as a network path on Windows and that WNetOpenEnum takes two seconds to execute, before failing with an exception. Tracing the code gives
$ perl -d:Trace -e 'use Cwd; print getcwd'
>> -e:1: use Cwd; print getcwd
>> /usr/lib/perl5/5.14/i686-cygwin-threads-64int/Cwd.pm:406:   *cwd = sub { &$orig_cwd() }
and this seems to be related to the following code.
if ($^O eq 'cygwin') {
  # We need to make sure cwd() is called with no args, because it's
  # got an arg-less prototype and will die if args are present.
  local $^W = 0;
  my $orig_cwd = \&cwd;
  *cwd = sub { &$orig_cwd() }
}

In reply to Re^4: File::Temp painfully slow under Cygwin by dds
in thread File::Temp painfully slow under Cygwin by dds

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.