Hi there,
I'm working on a Linux-based product using kernel v2.6.31 and bash v3.2.39.
I wrote a bash script to install updates on this product.
This script communicate trough pipes with a web-server running on the product.
When I read a pipe I use non-blocking mode to detect when the web-server is not ready to display information (I read the pipe and if there's no data coming from the web-server that means the web-server is not ready).
When the web-server doesn't write anything into the pipe the read command exists after a specified timeout (10 seconds) but sometimes the timeout is not correctly handled.
I wrote another script to test this issue. If I read two times the pipe, the second read operation will block if the first read operation exited with a timeout.
Here is the script.
Code:
#!/bin/bash
pipe="pipe"
pipe_fd=3
to=5
echo "Create pipe..."
mknod $pipe p
# open the pipe in read/write mode and keep it open (as in the update script)
echo "Open pipe in read/write mode."
eval "exec $pipe_fd<> $pipe"
# First read operation : We'll wait for the timeout
echo "Read pipe with timeout $to"
read -u $pipe_fd -t $to line
if [ $? = 0 ]; then
echo "OK : line=$line"
else
echo "ERROR"
fi
# Second read operation : We'll wait for the timeout (for ever :( )
echo "Read pipe with timeout $to"
read -u $pipe_fd -t $to line
if [ $? = 0 ]; then
echo "OK : line=$line"
else
echo "ERROR"
fi
# Close the pipe & remove it
eval "exec $pipe_fd>&-"
rm "$pipe"
I tried to run the script wish bash v4.1 and the same kernel v2.6.31 but the issue is still there => the issue is not in the read command.
The web-server has (sometimes) the same problem when reading a pipe => it confirms that the issue is not in the read command.
I executed this script on a PC with kernel v2.6.34.7 and bash v4.1.7 and everything works as expected.
My questions are...
- Does anyone know if a bug has been fixed about this issue in the recent kernel releases ?
- Is there a special option to set when compiling the kernel ?
- Is there another forum I could ask these questions ?
Thank for your help
alex