builtin bash echo failing - errno EINTR on multi-CPU machine
From:
Philippe Champagne
Subject:
builtin bash echo failing - errno EINTR on multi-CPU machine
Date:
Wed, 23 Jun 2004 18:22:49 -0700
Hi
I have a condition
where I get about 5% failures of echo in bash.
The failure rate
varies depending on the machine but easier to get on multiprocessor machine.
Actually, so far I was not able to reproduce it on a single CPU machine... (SMP
related?)
I'm running Linux
2.4.20 and GNU bash, version 2.05a.0(1)-release (i686-pc-linux-gnu) glibc
version is 2.2.5 but I tried on another machine that uses glibc 2.3.2
and all had the problem (all that have dual CPU or more)
With some debug
code, I found out errno is set to EINTR when we get the
error.
This errno is set
after a call to printf in the bash builtin echo C source
code.
I was hoping you
could help me figure out what's going on here.
Following are the 3
files required
mytest.sh is the
actual bash file with the failing echo
test.pkg is a file
mytest.sh uses
trun.sh
is a little
helper to run it many times.
Note: the "echo1
failed" or "echo2 failed" are the 2 locations where we hit the
problems.
(although as you can
see, we haven't check the exit code from all echo)
Any help will be
appreciated - thx
------------------mytest.sh
#!/bin/bash
ifs=$IFS IFS=$(echo -ne '\t\r\n')
while read sh_line
do #echo "sh_line:
[$sh_line]" if [ -z $sh_line
] then
## start reading files
first_line=0
while read line junk
do
IFS='
:'
read tag val < <(echo "$line")
if [ "$tag" = "filename" ];
then
fname="$val"
elif [ "$tag" = "size" ];
then
nbytes="$val"
elif [ -z $tag ] && [ -z $val ];
then
echo "
"
fi
# format the output
if [ ! -z "$tag" ] && [ ! -z "$val" ]; then
if [ $first_line -eq 1 ];
then
echo -n "| $tag: $val" || { echo $? echo "echo1 failed" exit
1 }
else
echo -n "$tag: $val" || { echo $? echo "echo2 failed" exit
1 }
first_line=1
fi
fi
# go back to reading one line at a
time.
IFS=$(echo -ne
'\t\r\n')
done fi done <
test.pkg exit 0 ------------- end
-------test.pkg file
needed by mytest.sh
name:
something description: A Simple Description platform: PC size:
14329
while true;
do let
i=$i+1 if ./mytest.sh;
then
let good=$good+1
else
let bad=$bad+1
fi if [ "$i" -eq 100 ];
then
echo "SUCCESSFUL: $good" >>
./result.txt
echo "FAIL CALLS: $bad" >>
./result.txt
let
good=0;
let
bad=0;
let
i=0; #
exit 0;
fi done --------------- end