delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/10/02/21:06:33

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:content-type:content-transfer-encoding
:mime-version:subject:message-id:date:to; q=dns; s=default; b=yp
RSJqjZyYtNy2tcONNuIUkzN1oqHLG2I1A6CDZZdogWfywnOUq4a25L1wkeVXebyv
OB/kWIfsh5RcvOrVACNvx/VNCbTfubxLNBqN9qKQbW4VnbmtduiVXTo0hHOW4RKW
7ateS0r/BPmjG3ssbVVd0sshD9YgvqKXMOnONasAs=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:content-type:content-transfer-encoding
:mime-version:subject:message-id:date:to; s=default; bh=Y46ybSlW
OErcpgydDR906Pnvb6k=; b=hncaU2SNb2neIbHrYZGmyBEI21u7BmAEIcpxogW8
K96c3us33LB8HBkCftDkLE7A6RHPLeI5FMLOMmyLeUy47FSvPrdMLWwvmgmksthk
JrusZsoMIyMR5/ceyboj9toPiu49yjSMbwNhoO2KLsDRF9No88eDTLEa32lT18Nw
sbo=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=hung
X-HELO: red.jenika.com
From: Matthew McGIllis <matthew AT mcgillis DOT org>
Mime-Version: 1.0 (Mac OS X Mail 11.0 \(3445.1.6\))
Subject: bash pipe race condition
Message-Id: <B05F4669-BE32-4C5C-B366-555CE37A6761@mcgillis.org>
Date: Mon, 2 Oct 2017 18:06:17 -0700
To: cygwin AT cygwin DOT com
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id v9316VSH010652

Windows 7 Service Pack 1
64-Bit Operating System

Cygwin
$ uname -r                                 
2.9.0(0.318/5/3)
$ uname -m                                 
x86_64                                                                

The basic issue is in a normal windows command shell if I do

$ .\input.exe | .\simple.exe                
line1
line2

If I use the same code from bash I get:

$ ./input.exe | ./simple.exe
line1
<—— Hangs indefinitely until you kill it or ctrl-c

Some how if input has a delay between its line output then things will get hung, if you remove the sleep from the input things work, add the sleep in it fails.


input.exe is generate from input.vb using: vbc input.vb

 input.vb file:
Module input
  Sub Main()
    Console.Out.WriteLine("line1")
    Threading.Thread.Sleep(2000)
    Console.Out.WriteLine("line2")
  End Sub
End Module

simple.exe is generated from simple.vb using: vbc simple.vb

simple.vb file:
Module simple
  Sub Main()
    Dim line As String
    line = Console.In.ReadLine()
    Do Until line Is Nothing
      Console.Out.WriteLine(line)
      line = Console.In.ReadLine()
    Loop
  End Sub
End Module

Microsoft (R) Visual Basic Compiler version 11.0.50938.18408

The above problem was found when attempting to use cygwin perl using IPC::Open2 to control stdin and stdout of a VB program. So this may not be a bash specific issue but some sort of generic pipe issue in cygwin.
--
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


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019