LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 02-04-2011, 05:07 AM   #1
agambier
LQ Newbie
 
Registered: Nov 2010
Location: Annecy, France
Distribution: Fedora 13
Posts: 22

Rep: Reputation: 2
reading pipes > sometimes blocks even in non-blocking mode


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
 
Old 03-10-2011, 12:13 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by agambier View Post
- Is there another forum I could ask these questions ?
You tried this? http://kernelnewbies.org/MailingList
 
Old 03-14-2011, 02:36 AM   #3
agambier
LQ Newbie
 
Registered: Nov 2010
Location: Annecy, France
Distribution: Fedora 13
Posts: 22

Original Poster
Rep: Reputation: 2
No not yet, thanks.
 
  


Reply

Tags
blocking, kernel, pipe



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
reading from named pipes versus urandom qweasd Linux - General 0 07-31-2010 05:55 PM
Question about reading/writing into a Named Pipes(FIFO) Sathya Programming 21 05-05-2008 08:39 AM
pipes - reading buffer less than PIPE_BUF is atomic operation? gal_netanel Programming 2 12-18-2007 12:28 AM
reading closed pipes kev000 Programming 2 11-29-2006 01:45 PM
Blocking IP's with IP Tables blocks actual traffic ninjaz Linux - Security 5 04-05-2006 05:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration