[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange behaviour on 'read' from a pipe
From: |
Lluís Batlle i Rossell |
Subject: |
Re: Strange behaviour on 'read' from a pipe |
Date: |
Mon, 2 Apr 2012 20:46:12 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Mon, Apr 02, 2012 at 04:39:19PM +0200, Lluís Batlle i Rossell wrote:
> Trying to reproduce the race, I got rid of 'sleep', and expected this to never
> hang. But it hangs where I try. Should I submit this to LKML maybe?
>
> I think it should not hang ever, but maybe I forecast something bad.
> -------------
> #!/var/run/current-system/sw/bin/bash
>
> PIPE=/tmp/pipe
>
> rm -f $PIPE
> mkfifo $PIPE
>
> function spawn {
> echo DONE > $PIPE
> }
>
> spawn sleep 1 &
>
> while true; do
> echo reading
> while read LINE < $PIPE; do
> echo $LINE
> spawn &
> done
> done
> ---------------
Adding a 'sleep 0.1' before 'echo DONE' makes it hang very early in three linux
machines I tried. Let me know if you can reproduce it. Let me know if this helps
you reproduce the problem. Here again:
----------
#!/bin/sh
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
-----------
- Re: Strange behaviour on 'read' from a pipe, Lluís Batlle i Rossell, 2012/04/01
- Re: Strange behaviour on 'read' from a pipe, Andreas Schwab, 2012/04/01
- Re: Strange behaviour on 'read' from a pipe, Lluís Batlle i Rossell, 2012/04/01
- Re: Strange behaviour on 'read' from a pipe, Chet Ramey, 2012/04/01
- Re: Strange behaviour on 'read' from a pipe, Lluís Batlle i Rossell, 2012/04/01
- Re: Strange behaviour on 'read' from a pipe, Chet Ramey, 2012/04/01
- Re: Strange behaviour on 'read' from a pipe, Lluís Batlle i Rossell, 2012/04/02
- Re: Strange behaviour on 'read' from a pipe, Lluís Batlle i Rossell, 2012/04/02
- Re: Strange behaviour on 'read' from a pipe,
Lluís Batlle i Rossell <=
- Re: Strange behaviour on 'read' from a pipe, Greg Wooledge, 2012/04/02
- Re: Strange behaviour on 'read' from a pipe, Lluís Batlle i Rossell, 2012/04/02