cat fifo hang [Re: [ANNOUNCEMENT] cygwin 3.3.0-0.2.6c1f49f83fde (TEST)]
Chris Roehrig
croehrig@house.org
Sun Oct 17 20:52:35 GMT 2021
On Sun Oct 17 2021, at 9:19 AM, Ken Brown via Cygwin <cygwin@cygwin.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@cygwin.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
More information about the Cygwin
mailing list