<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Ping!<br>
    </div>
    <blockquote cite="mid:544663D8.3030806@Gmail.com" type="cite">
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      Hi all,<br>
      <br>
      Attached is the patch that prevents ccc/c++-analyzer from hang if
      launched with ActivePerl or Strawberry Perl interpreters.<br>
      The patch replaces the code that creates a pipe from child to
      parent to the more portable explicit writing to parent, this
      prevent interpreters from hang.<br>
      The conditions for hang are: child should open a pipe to the
      parent and parent should read from the child, otherwise no hang.<br>
      <br>
      The problem is possibly caused by the bug in emulation of 'fork'
      by Perl interpreters on Windows. From <a moz-do-not-send="true"
        href="http://perldoc.perl.org/perlfork.html">perlfork</a>
      documentation, BUGS section:<br>
      "In certain cases, the OS-level handles created by the pipe(),
      socket(), and accept() operators are apparently not duplicated
      accurately in pseudo-processes. This only happens in some
      situations, but where it does happen, it may result in deadlocks
      between the read and write ends of pipe handles, or inability to
      send or receive data across socket handles."<br>
      <br>
      An example from perlfork documentation also hangs:<br>
      <br>
      # simulate open(FOO, "-|")<br>
      sub pipe_from_fork ($) {<br>
          my $parent = shift;<br>
          pipe $parent, my $child or die;<br>
          my $pid = fork();<br>
          die "fork() failed: $!" unless defined $pid;<br>
          if ($pid) {<br>
            close $child;<br>
          }<br>
          else {<br>
            close $parent;<br>
            open(STDOUT, ">&=" . fileno($child)) or die;<br>
          }<br>
        $pid;<br>
      }<br>
      <br>
      if (pipe_from_fork('BAR')) {<br>
      # parent<br>
      while (<BAR>) { print; }<br>
        close BAR;<br>
      }<br>
      else {<br>
        # child<br>
        print "pipe_from_fork\n";<br>
        exit(0);<br>
      }<br>
      <br>
      The hang is not reproduced only with the MSYS Perl.<br>
      <br>
      OK to commit?<br>
      <pre class="moz-signature" cols="72">-- 
Anton</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Anton</pre>
  </body>
</html>