[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange behaviour on 'read' from a pipe

From: Greg Wooledge
Subject: Re: Strange behaviour on 'read' from a pipe
Date: Mon, 2 Apr 2012 15:29:33 -0400
User-agent: Mutt/

On Mon, Apr 02, 2012 at 08:46:12PM +0200, Lluís Batlle i Rossell wrote:
> #!/bin/sh

You're running this in sh?  But reporting it as a bug in bash?

> PIPE=/tmp/pipe
> rm -f $PIPE
> mkfifo $PIPE
> set -x
> spawn() {
>     sleep 0.1
>     echo DONE > $PIPE
> }
> spawn &
> while true; do
>     while read LINE < $PIPE; do
>         echo $LINE
>         spawn &
>     done
> done

I ran this, with #!/bin/bash and with sleep 1 instead of sleep 0.1,
on an HP-UX 10.20 system and a Debian 6.0 (Linux) system.  For me,
it printed "DONE" once per second until I pressed ctrl-C, on both

Changing the sleep 1 back to sleep 0.1 and re-running on the Linux
system produced the same result, just 10 times as fast.

Changing the #!/bin/bash to #!/bin/sh and re-re-running on Linux
still produced the same result.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]