X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=BAYES_05,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org From: "David Kerrawn" To: Subject: Re: 1.7.10 : output from .NET programs does not get through pipeline Date: Mon, 26 Mar 2012 17:00:02 +0100 Message-ID: <004901cd0b69$816b58e0$84420aa0$@co.uk> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_004A_01CD0B71.E32FC0E0" X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com ------=_NextPart_000_004A_01CD0B71.E32FC0E0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I too have noticed this problem or a variation of it. I've narrowed it down to the change in pipe behavior in snapshot cygwin-src-20111023 Specifically in http://cygwin.com/snapshots/winsup-diffs-20111022-20111023 + Note that the write side of the pipe is opened as PIPE_TYPE_MESSAGE. + This *seems* to more closely mimic Linux pipe behavior and is + definitely required for pty handling since fhandler_pty_master + writes to the pipe in chunks, terminated by newline when CANON mode + is specified. */ r = CreateNamedPipe (pipename, PIPE_ACCESS_INBOUND | overlapped, - PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1, psize, + PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE, 1, psize, I took a copy of the 20111023 snapshot source and compiled cygwin1.dll, copied it to cygwin1.dll-message, patched the source back to the PIPE_TYPE_BYTE, recompiled and copied cygwin1.dll to cygwin1.dll-byte. Running a sample test case (attached), the output from any .NET application that I tried (eg MSBuild.exe) caused the pipe to close and I'd get no output. Non .NET applications like "cmd.exe /c ver" worked fine with both dlls. Importantly for me, if a program such as make is called where the MSBuild.exe is called from the Makefile not only is there no output from the MSBuild.exe command but the entire command tree resulting from the pipe exits immediately without any error or exception. Workarounds in the other posts to get the .NET application to even run including piping the output to another command loses the return code from the application or the output. My current workaround of recompiling cygwin1.dll from source with PIPE_TYPE_BYTE currently seems to work but it's probably going to cause other problems further down the line as this patch included some explanatory text stating why it is necessary. Regards David ------=_NextPart_000_004A_01CD0B71.E32FC0E0 Content-Type: application/octet-stream; name="safeopen.pl" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="safeopen.pl" #!/usr/bin/perl use strict; use warnings; use POSIX ":sys_wait_h"; # make STDOUT flush immediately $| =3D 1; my $cmd; $cmd =3D "/cygdrive/c/WINDOWS/Microsoft.NET/Framework/v3.5/MSBuild.exe -ver= sion"; run_cmd($cmd); $cmd =3D "/cygdrive/c/WINDOWS/SYSTEM32/cmd.exe /c ver"; run_cmd($cmd); sub run_cmd { my ($program) =3D @_; print "\nRunning command: $program\n"; my $pid =3D open(KID_TO_READ, "-|"); defined($pid) || die "can't fork: $!"; if ($pid) { # parent while () { print $_; } close(KID_TO_READ) || warn "kid exited $?"; } else { # child #($EUID, $EGID) =3D ($UID, $GID); # suid only exec($program,) || die "can't exec program: $!"; # NOTREACHED } } ------=_NextPart_000_004A_01CD0B71.E32FC0E0 Content-Type: text/plain; name="safeopen-output.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="safeopen-output.txt" =3D=3D=3D=3D=3D Incorrect Output =3D=3D=3D=3D=3D C:\cygwin\bin>copy cygwin1.dll-message cygwin1.dll Overwrite cygwin1.dll? (Yes/No/All): y 1 file(s) copied. build AT build06 ~ $ perl safeopen.pl Running command: /cygdrive/c/WINDOWS/Microsoft.NET/Framework/v3.5/MSBuild.e= xe -v ersion Running command: /cygdrive/c/WINDOWS/SYSTEM32/cmd.exe /c ver Microsoft Windows XP [Version 5.1.2600] build AT build06 ~ $ exit =3D=3D=3D=3D=3D Correct Output =3D=3D=3D=3D=3D C:\cygwin\bin>copy cygwin1.dll-byte cygwin1.dll Overwrite cygwin1.dll? (Yes/No/All): y 1 file(s) copied. build AT build06 ~ $ perl safeopen.pl Running command: /cygdrive/c/WINDOWS/Microsoft.NET/Framework/v3.5/MSBuild.e= xe -v ersion Microsoft (R) Build Engine Version 3.5.30729.1 [Microsoft .NET Framework, Version 2.0.50727.3625] Copyright (C) Microsoft Corporation 2007. All rights reserved. 3.5.30729.1 Running command: /cygdrive/c/WINDOWS/SYSTEM32/cmd.exe /c ver Microsoft Windows XP [Version 5.1.2600] build AT build06 ~ $ exit ------=_NextPart_000_004A_01CD0B71.E32FC0E0 Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ------=_NextPart_000_004A_01CD0B71.E32FC0E0--