[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
catching output from asynchronous processes
From: |
Ralf Wildenhues |
Subject: |
catching output from asynchronous processes |
Date: |
Mon, 8 Nov 2010 22:14:37 +0100 |
User-agent: |
Mutt/1.5.20 (2010-08-04) |
Hi Ole, bug-parallel readers,
you asked whether I could reproduce output loss with background shell
processes when O_APPEND is not used. With the following snippet, I
can reliably produce a failure on an otherwise idle two-way GNU/Linux
system:
$ sh -c 'n=1
while :; do
{ echo 1 & echo 2; wait; } > file
test `wc -l < file` -eq 2 || { echo $? $n; break; }
n=$((n+1))
done'
with sh being either bash 4.1.5 or dash 0.5.5.1. On this system, $n
is usually a few hundred, with the lowest in a number of tries being
81 and the highest in the 500s. The failure of course does not occur
with
$ sh -c 'n=1
while :; do
: > file
{ echo 1 & echo 2; wait; } >> file
test `wc -l < file` -eq 2 || { echo $? $n; break; }
n=$((n+1))
done'
and the counting is of course only for statistics and has nothing to do
with exposing the issue. Similarly, the failure of course does not
occur if you pipe the output into another process, or into a named pipe.
This is probably very hard to reproduce on a single processor system.
Cheers,
Ralf
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- catching output from asynchronous processes,
Ralf Wildenhues <=