<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06.11.2014 20:27, Jordan Rose wrote:<br>
    </div>
    <blockquote
      cite="mid:B62F3D71-2012-4327-9115-4153F880A7AE@apple.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      <div class="">I think my point was "why bother forking at all if
        we're using open to run a subprocess?".</div>
    </blockquote>
    Ah, got it! Attached is an updated patch.<br>
    <br>
    <blockquote
      cite="mid:B62F3D71-2012-4327-9115-4153F880A7AE@apple.com"
      type="cite">
      <div class=""><br class="">
      </div>
      <div class="">Also, this will fail if the path contains spaces:</div>
    </blockquote>
    Corrected.<br>
    <br>
    <blockquote
      cite="mid:B62F3D71-2012-4327-9115-4153F880A7AE@apple.com"
      type="cite">
      <div class=""><br class="">
      </div>
      <div class="">
        <div class="">+    my $ExecLine = join(' ', $Clang, "-###",
          $mode, @$Args, "2>&1", "|");</div>
        <div class="">+    open(PS, $ExecLine);</div>
      </div>
      <div class=""><br class="">
      </div>
      <div class="">Do newer Perls on newer Windows support the list
        form of open?</div>
    </blockquote>
    No, at least ActivePerl, StrawberryPerl and Dwimperl.<br>
    <br>
    Current perl docs state:<br>
    'open to <code class="inline">|-</code> and <code class="inline">-|</code>
    are unsupported. (Win32, RISC OS)' (<a
      href="http://perldoc.perl.org/perlport.html#open">http://perldoc.perl.org/perlport.html#open</a>)<br>
    and<br>
    'The open(FOO, "|-") and open(BAR, "-|") constructs are not yet
    implemented.' (<a href="http://perldoc.perl.org/perlfork.html">http://perldoc.perl.org/perlfork.html</a>)<br>
    <br>
    <blockquote
      cite="mid:B62F3D71-2012-4327-9115-4153F880A7AE@apple.com"
      type="cite">
      <div class="">Jordan</div>
      <div class=""><br class="">
      </div>
      <br class="">
      <div>
        <blockquote type="cite" class="">
          <div class="">On Nov 5, 2014, at 11:54 , Anton Yartsev <<a
              moz-do-not-send="true"
              href="mailto:anton.yartsev@gmail.com" class="">anton.yartsev@gmail.com</a>>

            wrote:</div>
          <br class="Apple-interchange-newline">
          <div class="">
            <meta content="text/html; charset=windows-1252"
              http-equiv="Content-Type" class="">
            <div bgcolor="#FFFFFF" text="#000000" class="">
              <div class="moz-cite-prefix">Ping!<br class="">
              </div>
              <blockquote cite="mid:5452879E.5080509@Gmail.com"
                type="cite" class="">
                <meta content="text/html; charset=windows-1252"
                  http-equiv="Content-Type" class="">
                <div class="moz-cite-prefix">It seems that fork is the
                  only native perl mean for creating subprocesses. There
                  is a number of packages that provide means for
                  spawning at <a moz-do-not-send="true"
                    href="http://cpan.org" class="">cpan.org</a>, but
                  they are not guarantee to be included at the users
                  perl distribution.</div>
                <blockquote
                  cite="mid:658A0B49-9795-4D6E-AA12-363D7CD99B02@apple.com"
                  type="cite" class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=windows-1252" class="">
                  <div class="">Looking at this code, it's weird that
                    we're doing this as a fork/exec (or not-exec) at
                    all. Why can't we just spawn a sub-process?</div>
                  <div class=""><br class="">
                  </div>
                  <div class="">Jordan</div>
                  <div class=""><br class="">
                  </div>
                  <br class="">
                  <div class="">
                    <div class="">On Oct 21, 2014, at 6:47 , Anton
                      Yartsev <<a moz-do-not-send="true"
                        href="mailto:anton.yartsev@gmail.com" class="">anton.yartsev@gmail.com</a>>



                      wrote:</div>
                    <br class="Apple-interchange-newline">
                    <blockquote type="cite" class="">
                      <meta http-equiv="content-type"
                        content="text/html; charset=windows-1252"
                        class="">
                      <div bgcolor="#FFFFFF" text="#000000" class=""> Hi
                        all,<br class="">
                        <br class="">
                        Attached is the patch that prevents
                        ccc/c++-analyzer from hang if launched with
                        ActivePerl or Strawberry Perl interpreters.<br
                          class="">
                        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 class="">
                        The conditions for hang are: child should open a
                        pipe to the parent and parent should read from
                        the child, otherwise no hang.<br class="">
                        <br class="">
                        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"
                          class="">perlfork</a> documentation, BUGS
                        section:<br class="">
                        "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 class="">
                        <br class="">
                        An example from perlfork documentation also
                        hangs:<br class="">
                        <br class="">
                        # simulate open(FOO, "-|")<br class="">
                        sub pipe_from_fork ($) {<br class="">
                            my $parent = shift;<br class="">
                            pipe $parent, my $child or die;<br class="">
                            my $pid = fork();<br class="">
                            die "fork() failed: $!" unless defined $pid;<br
                          class="">
                            if ($pid) {<br class="">
                              close $child;<br class="">
                            }<br class="">
                            else {<br class="">
                              close $parent;<br class="">
                              open(STDOUT, ">&=" .
                        fileno($child)) or die;<br class="">
                            }<br class="">
                          $pid;<br class="">
                        }<br class="">
                        <br class="">
                        if (pipe_from_fork('BAR')) {<br class="">
                        # parent<br class="">
                        while (<BAR>) { print; }<br class="">
                          close BAR;<br class="">
                        }<br class="">
                        else {<br class="">
                          # child<br class="">
                          print "pipe_from_fork\n";<br class="">
                          exit(0);<br class="">
                        }<br class="">
                        <br class="">
                        The hang is not reproduced only with the MSYS
                        Perl.<br class="">
                        <br class="">
                        OK to commit?<br class="">
                        <pre class="moz-signature" cols="72">-- 
Anton</pre>
                      </div>
                      <span class=""><ccc-analyzer_fork_open_hang.patch></span></blockquote>
                  </div>
                  <br class="">
                </blockquote>
                <br class="">
                <br class="">
                <pre class="moz-signature" cols="72">-- 
Anton</pre>
              </blockquote>
              <br class="">
              <br class="">
              <pre class="moz-signature" cols="72">-- 
Anton</pre>
            </div>
          </div>
        </blockquote>
      </div>
      <br class="">
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Anton</pre>
  </body>
</html>