Bug 18372 (TOM) - A filled up named pipe always has a size of zero!
Summary: A filled up named pipe always has a size of zero!
Status: CLOSED WILL_NOT_FIX
Alias: TOM
Product: File System
Classification: Unclassified
Component: ext4 (show other bugs)
Hardware: All Linux
: P1 high
Assignee: fs_ext4@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-12 21:47 UTC by TOM
Modified: 2012-05-12 15:46 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.32-22-generic (also older and newer ones)
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description TOM 2010-09-12 21:47:01 UTC
Hi, there!

The size of a filled named pipe is always zero. This is wrong! A read operation is going to hang for try to read from an empty pipe. To go around this trap it is necessary to do a conditional test on the filesize, [ -s pipe ]. Problem: The test doesn't work, because filesize is always zero.

Try:
mknod pipe &
sleep 3600  <>pipe &
echo 'date' >pipe
[ -s pipe ] && echo "filled up"
ls -l pipe; stat pipe	# if size zero, it is wrong
[ -s pipe ] && (read val <pipe; echo $val)


This is a critical error. While parallel processing a script would be blocked. In worst case it causes a deadlock situation. Every changing of a condition of a file should be reported whithin the i-node. 

I found it in several disto: Ubuntu KarmicKoala 9.1, LucidLynx 10.04,
Linux Mint Debian Edition 5, Slackware 13.1 x64
 
Best regards
TOM
Comment 1 Alan 2012-05-12 15:46:52 UTC
Not a bug - its the correct behaviour as per spec.

Note You need to log in before you can comment on or make changes to this bug.