delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2021/10/17/16:52:56

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 063A03858D28
Authentication-Results: sourceware.org;
dmarc=none (p=none dis=none) header.from=house.org
Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=house.org
X-Virus-Scanned: Debian amavisd-new at emo02-pco.easydns.vpn
Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\))
Subject: cat fifo hang [Re: [ANNOUNCEMENT] cygwin 3.3.0-0.2.6c1f49f83fde
(TEST)]
From: Chris Roehrig <croehrig AT house DOT org>
In-Reply-To: <2c263022-b361-f697-ca7b-5caface23872@cornell.edu>
Date: Sun, 17 Oct 2021 13:52:35 -0700
Message-Id: <3734589D-7DB4-41F1-9BE6-AF3A36693397@house.org>
References: <announce DOT e0fa65d0-dd68-5ffe-a177-0eca4b499bc2 AT cornell DOT edu>
<9D395D88-1D8A-4C8B-9C96-32734D14C4D7 AT house DOT org>
<13495a25-2ae9-69f9-cd8e-6e6ff0e1af9e AT cornell DOT edu>
<E0CDBC6F-4F84-495A-BCA4-A7B049BA8928 AT house DOT org>
<2c263022-b361-f697-ca7b-5caface23872 AT cornell DOT edu>
To: Ken Brown via Cygwin <cygwin AT cygwin DOT com>
X-Mailer: Apple Mail (2.1499)
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

On Sun Oct 17 2021, at 9:19 AM, Ken Brown via Cygwin <cygwin AT cygwin DOT com> wrote:

> On 10/16/2021 1:42 PM, Chris Roehrig wrote:
>> On Mon Sep 27 2021, at 7:26 AM, Ken Brown via Cygwin <cygwin AT cygwin DOT com> wrote:
>>> On 9/26/2021 8:57 PM, Chris Roehrig wrote:
>>>> I have installed this (completely this time) and have encountered no issues with it.  I'm getting full gigabit speeds with my rsync transfers.   Looks great!
>>> 
>>> Thanks for testing.
>> I've encountered a crash that might be related.   I had previously been having occasional crashes/hangs of cat.exe over the years, but this is the first time I've ever gotten an error message:
>> cygwin error: 0 [fifo_reader] cat 11398 C:\cygwin\bin\cat.exe: *** fatal  error - Can't add a client handler, Win32 error 123
> 
> This isn't a crash in the usual sense.  It's the Cygwin fifo code issuing a fatal error because an attempt to create a new Windows pipe instance failed. And it's in code that's been around for a while, so it's not related to the new pipe implementation.
> 
>> cat here is reading from a fifo created with mkfifo.
>> I've only encountered it once (out of daily runs over the last couple weeks) and don't know how to replicate it.   Possibly a race?    Looks like my script has tried to mitigate this with a sleep 1 between the mkfifo and the fork: cat < $fifo &
> 
> The sleep shouldn't be necessary.  If it is, there's a bug in the fifo code. Can you remove the sleep and see what happens?  It would be great if that made it possible to replicate the problem.

Here's a script that pretty reliably hangs cat after some iterations.    I haven't yet gotten a repeat of that error message though.
It runs fine on Ubuntu 20.04 and Mac OS X 10.8.4.


#!/bin/bash

# take arg as number of iterations (default=100)
STEPS="${1-100}"

FIFO_PFX="/tmp/catfifo_"
FIFO_WAIT=0
STEP_WAIT=0

function mysleep() { if [ -n "$1" -a "$1" != "0" ]; then sleep "$1"; fi }

function cleanup(){
	rm -f "$FIFO_PFX"*
}
trap cleanup EXIT

printf "Creating $STEPS fifo readers...\n"
for ((i=0; i<STEPS; i++ )); do
	fifo="$FIFO_PFX$i"

	# create fifo
	mkfifo "$fifo"
	mysleep $FIFO_WAIT

	# fork a process reading from fifo and writing it to stdout
	cat < "$fifo" &
	pid=$!
	printf "Created PID=$pid  reading from $fifo\n"

	# redirect FD3 to the fifo and print a message to it
	exec 3>"$fifo"		
	printf "FIFO %d\n" "$i" >&3

	# close the file descriptor, wait for process to exit and clean up
	exec 3>&-
	wait $pid
	rm -f "$fifo"

	mysleep $STEP_WAIT
done


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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